Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , 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" To: Subject: RE: Grep and matching end of line (anchoring) Date: Fri, 19 Nov 2004 18:29:43 -0000 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit In-Reply-To: Message-ID: X-OriginalArrivalTime: 19 Nov 2004 18:29:43.0437 (UTC) FILETIME=[BD3173D0:01C4CE65] > -----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 AT mace /test/grep-test> od -c test.dos.txt 0000000 H e l l o w o r l d \r \n 0000015 dk AT mace /test/grep-test> od -c test.unix.txt 0000000 H e l l o w o r l d \n 0000014 dk AT mace /test/grep-test> grep -E 'ld^M?$' * dk AT mace /test/grep-test> grep -E 'd^M?$' * dk AT mace /test/grep-test> grep -E '.^M?$' * dk AT mace /test/grep-test> Grep knows there's a char there, but it won't match it with ^M. dk AT mace /test/grep-test> grep -E '.$' * test.dos.txt:Hello world test.unix.txt:Hello world dk AT mace /test/grep-test> grep -E 'd.$' * test.dos.txt:Hello world dk AT mace /test/grep-test> grep -E 'd^M$' * dk AT mace /test/grep-test> grep -E 'd^m$' * dk AT 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/