| delorie.com/archives/browse.cgi | search |
| 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:29:43 -0000 |
| MIME-Version: | 1.0 |
| In-Reply-To: | <F76C9B2DA2FC4C4CA0A18E288BBCBCF71026EB0B@nihexchange24.nih.gov> |
| Message-ID: | <NUTMEGc0xvlUQ9cAgjH000000f0@NUTMEG.CAM.ARTIMI.COM> |
| 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/
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |