bug-grep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#25513: Issue grepping lines ending with CRLF with --color=auto.


From: Eric Hoffman
Subject: bug#25513: Issue grepping lines ending with CRLF with --color=auto.
Date: Mon, 23 Jan 2017 16:03:49 +0000

Hello!

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

That is, I tell grep to display every lines containing at least one character 
(that is, every lines),  I get on terminal output just 3 empty lines.  However, 
if I type:
$ grep "." test.txt
Line 1
Line 2
Line 3

Then I do have every lines on the output.

I tried on both SSH and direct console with same result.

On my SSH terminal, I captured output, and what I see is
<CR><LF>
<CR><LF>
<CR><LF>

Here are a few variations:
- I tried with a longer file, like 100 lines, and I do get some of the lines 
printed, but truncated to the terminal screen width.
- The issue here was with printing every lines, but I do get the same result as 
long as I match any end of lines, like grep "2.*" test.txt, or even "grep 
2[[:cntrl:]]$" test.txt
- The problem is there only when

This was with grep 2.27 (also tried 2.16, which I had before upgrading to 2.27).

Regards,
Eric



reply via email to

[Prev in Thread] Current Thread [Next in Thread]