GNU Awk 4.0.1: Cygwin's awk is filtering CR from the input

Corinna Vinschen corinna-cygwin@cygwin.com
Tue Jun 17 16:02:00 GMT 2014


On Jun 17 10:57, James Calfee wrote:
> "It seems like the issue is awk specific under Cygwin.  I tried a few
> different things and it seems that awk is silently treating replacing
> \r\n with \n in the input data."
> 
> See stack overflow ticket #24251296
> titled: does-awk-cr-lf-handling-break-on-cygwin
> 
> Unfortunately the spam filter rejects links to stack overflow (already
> a spam filtered site)
> 
> On Linux (good, we have cr and nl)
> $ echo $'line1\r\nline2'|awk 1|od -a
> 0000000   l   i   n   e   1  cr  nl   l   i   n   e   2  nl
> 0000015
> 
> On Cygwin or MSYS (bad, we have only a cr)
> $ echo $'line1\r\nline2'|awk 1|od -a
> 0000000   l   i   n   e   1  nl   l   i   n   e   2  nl
> 0000014

This is by design.  The Cygwin version of gawk is by default always
writing POSIX line endings to stdout.  Try using the BINMODE option:

  echo $'line1\r\nline2'|awk -v BINMODE=1 1|od -a


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin/attachments/20140617/aaad6d31/attachment.sig>


More information about the Cygwin mailing list