delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2005/09/08/11:04:41

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: ericblake AT comcast DOT net (Eric Blake)
To: Public Mailing Lists <lists AT lists DOT cichon DOT com>, cygwin AT cygwin DOT com
Subject: Re: xargs still nok?
Date: Thu, 08 Sep 2005 15:04:25 +0000
Message-Id: <090820051504.15123.432052F900038A8700003B1322064246130A050E040D0C079D0A@comcast.net>
X-Authenticated-Sender: ZXJpY2JsYWtlQGNvbWNhc3QubmV0

> You could either use
> 
> find . -name '*.cfm' -exec grep -i something {} /dev/null \;
> 
> which would make grep to show the filename. grep will think that it 
> searches multiple files, and will not find something in /dev/null. This 
> solution works well under Unix. With Cygwin, you may not have devices 
> available in /dev, depending on your installation.

Don't spread misinformation.  Cygwin is a Unix environment
emulation, so /dev/null ALWAYS exists (none of this junk about
"depending on your installation").

But in general, your point is accurate, and not just for single
grep invocations - if you are using the grouping features of find
or xargs to invoke grep, and want to insure that grep behaves
as though it is searching multiple files (so that it will print
filenames on the line), then add /dev/null in addition to the
list of found files, in case only one file is found or the list gets
split such that the final invocation is on just one file.  It is also
helpful with xargs when you are not using the -r option, because
then even if no files are found, xargs will still invoke grep and
grep needs a filename to search.

--
Eric Blake



--
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