This is the mail archive of the
cygwin
mailing list for the Cygwin project.
RE: Grep and matching end of line (anchoring)
- From: "Dave Korn" <dk at artimi dot com>
- To: <cygwin at cygwin dot com>
- Date: Fri, 19 Nov 2004 18:29:43 -0000
- Subject: RE: Grep and matching end of line (anchoring)
> -----Original Message-----
> From: cygwin-owner On Behalf Of Buchbinder, Barry (NIH/NIAID)
> Sent: 19 November 2004 15:17
> This should work whether or not one is on a text mount or for
> the file has DOS or Unix line endings:
>
> cat files.txt | grep -E '\.h^M?$'
Always test before posting. Even a one liner. That doesn't work, or at
least NFM:
dk@mace /test/grep-test> od -c test.dos.txt
0000000 H e l l o w o r l d \r \n
0000015
dk@mace /test/grep-test> od -c test.unix.txt
0000000 H e l l o w o r l d \n
0000014
dk@mace /test/grep-test> grep -E 'ld^M?$' *
dk@mace /test/grep-test> grep -E 'd^M?$' *
dk@mace /test/grep-test> grep -E '.^M?$' *
dk@mace /test/grep-test>
Grep knows there's a char there, but it won't match it with ^M.
dk@mace /test/grep-test> grep -E '.$' *
test.dos.txt:Hello world
test.unix.txt:Hello world
dk@mace /test/grep-test> grep -E 'd.$' *
test.dos.txt:Hello world
dk@mace /test/grep-test> grep -E 'd^M$' *
dk@mace /test/grep-test> grep -E 'd^m$' *
dk@mace /test/grep-test>
What makes you think grep understands ^ notation to indicate control
chars? It doesn't say so in the info page. (It doesn't recognize [\r]
either.)
Actually, it seems that grep
cheers,
DaveK
--
Can't think of a witty .sigline today....
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/