This is the mail archive of the mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

awk strangely outputs to file

Hi all,

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

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:
	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
awk -v v_OutFile="//c/x" -f example.awk /etc/passwd
results in a POSIX output file :(

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

$ mount -p
Prefix              Type         Flags
//                  system       textmode

$ awk --version
GNU Awk 3.1.1

$ 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.


Unsubscribe info:
Bug reporting:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]