Grep sometimes displays empty lines instead of search results. Reproducible: Always Steps to Reproduce: Give a command like grep 's.*' grep-testcase.txt Actual Results: Displays an empty line for each line in the file 'grep-testcase.txt' with the letter 's'. Expected Results: Should display lines containing the letter 's' with the fragment from the first 's' to the end of the line highlighted. I was able to reproduce it only on files with DOS/Windows end-of-line (0d 0a).
Created attachment 132773 [details] A n example file where grep fails grep 's.*' grep-testcase.txt gives 5 empty lines, and so does grep -P 's.*' grep-testcase.txt . grep -P 's.*\n' grep-testcase.txt works.
The problem remains in sys-apps/grep-2.5.3 The output looks OK with --colour=never switch. Maybe the problem is with highlighting the text? Vanilla grep 2.5.1 and 2.5.3 from gnu.org works fine.
use `dos2unix` on the file first and it'll work fine
It's hard to use dos2unix on read-only files. But --colour=never seems to be enough.
running sed on a read-only file and piping it into grep works fine too grep-2.6 is still broken (as expected)
i'm not sure this will ever really get fixed ... it's a crap situation. see this for more info: http://git.savannah.gnu.org/cgit/grep.git/tree/src/main.c?id=88d65410f7aa472c66da1bdf01c3cc1439cefce6#n142 you should be able to workaround it by doing: export GREP_COLORS=ne in your ~/.bash_profile or wherever