GNU bug report logs -
#25513
Issue grepping lines ending with CRLF with --color=auto.
Previous Next
Full log
Message #10 received at 25513-done <at> debbugs.gnu.org (full text, mbox):
tags 25513 notabug
thanks
On Mon, Jan 23, 2017 at 8:03 AM, Eric Hoffman
<ehoffman <at> positronaccess.com> wrote:
> grep is behaving differently when outputting with --color=auto when lines are ending with CRLF (like Windows text files).
>
> The issue is that if I have a file with CRLF line terminator, for example, a file named test.txt, containing:
> Line 1<CR><LF>
> Line 2<CR><LF>
> Line 3<CR><LF>
>
> Or:
>
> $od -c test.txt
> 0000000 L i n e 1 \r \n L i n e 2 \r \n
> 0000020 L i n e 3 \r \n
> 0000030
>
> Then, If I type:
> $ grep --color=auto "." test.txt
...
Thank you for the report. I too see that behavior, but it is not a
problem with grep. It is due to the way carriage returns are rendered.
Here, even without --color, you can see that the three matched line
render as empty:
$ printf 'line%s\r\n' 1 2 3 | grep .
However, if you pipe that result through cat -A, you see that grep is
working as required:
$ printf 'line%s\r\n' 1 2 3 | grep .|cat -A
line1^M$
line2^M$
line3^M$
So I'm closing this bug.
This bug report was last modified 8 years and 141 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.