This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Re: grep 3.0-2 not stripping CRs on Windows
- From: Steven Penny <svnpenn at gmail dot com>
- To: cygwin at cygwin dot com
- Date: Mon, 17 Dec 2018 05:05:48 -0800 (PST)
- Subject: Re: grep 3.0-2 not stripping CRs on Windows
- References: <35FC3865-8891-4058-86DF-DA5F1DEFAFD4@isc.org>
On Mon, 17 Dec 2018 13:22:48, Ondřej Surý wrote:
# No amount of options makes the grep find the text in the file
$ ./grep-3.0-2.exe 'foo$’ crlf.txt
$ ./grep-3.0-2.exe -U 'foo$' crlf.txt
$ ./grep-3.0-2.exe -a 'foo$’ crlf.txt
Your commands are failing because you are not accounding for the carriage
returns. as was said, this change was intentionally done for the purpose of
making scripts MORE portable:
https://cygwin.com/ml/cygwin/2017-02/msg00155.html
if you want to keep your grep command, you need to remove CR first:
$ printf 'alpha\r\nbeta\r\n' > CRLF.txt
$ tr -d '\r' < CRLF.txt | grep 'a$'
alpha
beta
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple