This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: Grep and matching end of line (anchoring)


> -----Original Message-----
> From: cygwin-owner On Behalf Of Dave Korn
> Sent: 19 November 2004 18:30

>   Actually, it seems that grep
> 


... cannot be blamed for failing to spot _that_ unexpected EOL!

  What I was going to say is that it seems egrep doesn't properly handle the
^ symbol at all, except when it's being used as a start-of-line anchor or
character-class negator.  If I read the docs right, ^ ought to have no
special significance when not appearing either at the start of the line or
as the first entry in a character class.

dk@mace /test/grep-test> od -c badgrep.txt
0000000   a   b   c   d   ^   x   y   z
0000010
dk@mace /test/grep-test> grep d^ badgrep.txt
dk@mace /test/grep-test> grep .^ badgrep.txt
abcd^xyz
dk@mace /test/grep-test> grep -E d^ badgrep.txt
dk@mace /test/grep-test> grep -E .^ badgrep.txt
dk@mace /test/grep-test> grep d\^ badgrep.txt
dk@mace /test/grep-test> grep .\^ badgrep.txt
abcd^xyz
dk@mace /test/grep-test> grep -E d\^ badgrep.txt
dk@mace /test/grep-test> grep -E .\^ badgrep.txt
dk@mace /test/grep-test> grep 'd^' badgrep.txt
dk@mace /test/grep-test> grep '.^' badgrep.txt
abcd^xyz
dk@mace /test/grep-test> grep -E 'd^' badgrep.txt
dk@mace /test/grep-test> grep -E '.^' badgrep.txt
dk@mace /test/grep-test> grep 'd\^' badgrep.txt
abcd^xyz
dk@mace /test/grep-test> grep '.\^' badgrep.txt
abcd^xyz
dk@mace /test/grep-test> grep -E 'd\^' badgrep.txt
abcd^xyz
dk@mace /test/grep-test> grep -E '.\^' badgrep.txt
abcd^xyz
dk@mace /test/grep-test>


  It seems to need both quoting _and_ escaping.  Is that to be expected?
Ah, no, hang on; if not quoted, the escaping gets swallowed by the shell,
but you you can prevent that by double escaping it.

  But it still seems to need escaping to avoid grep treating it as a
metachar, even when it's not syntactically possible for it to be one.


    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/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]