delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2004/11/19/13:55:47

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
From: "Dave Korn" <dk AT artimi DOT com>
To: <cygwin AT cygwin DOT com>
Subject: RE: Grep and matching end of line (anchoring)
Date: Fri, 19 Nov 2004 18:54:25 -0000
MIME-Version: 1.0
In-Reply-To: <NUTMEGc0xvlUQ9cAgjH000000f0@NUTMEG.CAM.ARTIMI.COM>
Message-ID: <NUTMEGV1EetVoMDrxxn000000f2@NUTMEG.CAM.ARTIMI.COM>
X-OriginalArrivalTime: 19 Nov 2004 18:54:25.0468 (UTC) FILETIME=[308D6FC0:01C4CE69]

> -----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 AT mace /test/grep-test> od -c badgrep.txt
0000000   a   b   c   d   ^   x   y   z
0000010
dk AT mace /test/grep-test> grep d^ badgrep.txt
dk AT mace /test/grep-test> grep .^ badgrep.txt
abcd^xyz
dk AT mace /test/grep-test> grep -E d^ badgrep.txt
dk AT mace /test/grep-test> grep -E .^ badgrep.txt
dk AT mace /test/grep-test> grep d\^ badgrep.txt
dk AT mace /test/grep-test> grep .\^ badgrep.txt
abcd^xyz
dk AT mace /test/grep-test> grep -E d\^ badgrep.txt
dk AT mace /test/grep-test> grep -E .\^ badgrep.txt
dk AT mace /test/grep-test> grep 'd^' badgrep.txt
dk AT mace /test/grep-test> grep '.^' badgrep.txt
abcd^xyz
dk AT mace /test/grep-test> grep -E 'd^' badgrep.txt
dk AT mace /test/grep-test> grep -E '.^' badgrep.txt
dk AT mace /test/grep-test> grep 'd\^' badgrep.txt
abcd^xyz
dk AT mace /test/grep-test> grep '.\^' badgrep.txt
abcd^xyz
dk AT mace /test/grep-test> grep -E 'd\^' badgrep.txt
abcd^xyz
dk AT mace /test/grep-test> grep -E '.\^' badgrep.txt
abcd^xyz
dk AT 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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019