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 |
Message-ID: | <419DE9E7.2060906@x-ray.at> |
Date: | Fri, 19 Nov 2004 13:41:11 +0100 |
From: | Reini Urban <rurban AT x-ray DOT at> |
User-Agent: | Mozilla/5.0 (Windows; U; Windows NT 5.0; de-AT; rv:1.8a4) Gecko/20040927 |
MIME-Version: | 1.0 |
To: | "Dalton, Barnaby" <Barnaby DOT Dalton AT radioscape DOT com> |
CC: | "'cygwin AT cygwin DOT com'" <cygwin AT cygwin DOT com> |
Subject: | Re: Grep and matching end of line (anchoring) |
References: | <5D139685F337FC44A97D330F8F1BF6FA07DEEB AT MORSE> |
In-Reply-To: | <5D139685F337FC44A97D330F8F1BF6FA07DEEB@MORSE> |
X-IsSubscribed: | yes |
Dalton, Barnaby schrieb: > I'm having trouble gettting grep to match end of line when used with > files/utlilities that use DOS linefeeds. For example: > > cat files.txt | grep '\.h$' > > produces no output. However, if I stick a filter in the middle to change the > line endings: > > cat files.txt | perl -pe 's/\r\n/\n/' | grep '\.h$' > I get: > > file1.h > file2.h > > as expected. pipes are treated as binmode, so they don't convert eol from \r\n to \n. without pipe it should work on a textmount: grep '\.h$' files.txt or grep '\.h$' < files.txt > Should grep's $ match \r\n or should I expect to have to convert line > endings? grep's "$" is not expected to do textmode magic if stdin is binmode. BTW: cat files.txt | sed 's,\r\n,\n,' | grep '\.h$' is simplier. Someone might think of a new textmode pipe operator (like a new "t|"), but I don't consider that a good idea. man bash /REDIRECTION and /Pipelines -- Reini Urban http://xarch.tu-graz.ac.at/home/rurban/ -- 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 |