awk strangely outputs to file

Harald Kierer Harald.Kierer@astrum.de
Mon Feb 3 14:30:00 GMT 2003


Hi all,

my awk (which is actually gawk) shows strange End-Of-Line-behaviour
when redirecting the output to a file.

Note:
I use the old drive prefix "//" because of old scripts;
works perfect currently.

Example in bash:

$ awk '{ print "123\n456" } ' /etc/passwd > "c:/x"
(the /etc/passwd is just there to issue some loops)
(every other target drive works the same as c)

$ notepad "c:\x"
( => all in one line)

$ awk '{ print "123\n456" } ' /etc/passwd > "//c/x"

$ notepad "c:\x"
(several lines with Windows CR/LF)

The reason why I tested this is an awk script that writes
some lines directly to a file and always ends up with
a POSIX style output file. That worked different with our
previous cygwin environment (very old).

An example awk-file showing this:
---
BEGIN	{
	print "123" > v_OutFile;
	print "456" > v_OutFile;
	print "789" > v_OutFile;
}
---

Calling it with
awk -v v_OutFile="c:/x" -f example.awk /etc/passwd
and
awk -v v_OutFile="//c/x" -f example.awk /etc/passwd
results in a POSIX output file :(

$ mount
[snip]
c: on //c type user (textmode,noumount)
[snip]

$ mount -p
Prefix              Type         Flags
//                  system       textmode

$ awk --version
GNU Awk 3.1.1
[snip]

$ uname -a
CYGWIN_NT-5.0 RE0263 1.3.19s(0.71/3/2) 20030119 22:03:54 i686 unknown
unknown Cygwin


How can awk write Windows-like text files from within the script?
The only way right now is to redirect the whole output like above.

Bye,
 Harry

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/



More information about the Cygwin mailing list