Pesquisando com várias entradas, senti que grep
fez sua própria mágica para fins de linha:
$ printf "foo\rbar\n" | grep -oz $'\r' | od -c
0000000 \r \n
0000002
$ printf "foo\rbar\r\n" | grep -oz $'\r' | od -c
0000000
$ printf "foo\rbar\r" | grep -oz $'\r' | od -c
0000000 \r \n \r \n
0000004
(O -z
foi minha tentativa fraquinha de fazer com que grep
correspondesse a tudo.) E então eu procurei na página de manual por LF
, levando-me a:
-U, --binary
Treat the file(s) as binary. By default, under MS-DOS and MS-
Windows, grep guesses the file type by looking at the contents
of the first 32KB read from the file. If grep decides the file
is a text file, it strips the CR characters from the original
file contents (to make regular expressions with ^ and $ work
correctly). Specifying -U overrules this guesswork, causing all
files to be read and passed to the matching mechanism verbatim;
if the file is a text file with CR/LF pairs at the end of each
line, this will cause some regular expressions to fail. This
option has no effect on platforms other than MS-DOS and MS-
Windows.