www.delorie.com/archives/browse.cgi | search |
X-Recipient: | archive-cygwin AT delorie DOT com |
X-SWARE-Spam-Status: | No, hits=-1.5 required=5.0 tests=AWL,BAYES_00,J_CHICKENPOX_22,SARE_MSGID_LONG40,SPF_PASS |
X-Spam-Check-By: | sourceware.org |
MIME-Version: | 1.0 |
In-Reply-To: | <24359078.post@talk.nabble.com> |
References: | <24359078 DOT post AT talk DOT nabble DOT com> |
Date: | Mon, 6 Jul 2009 13:17:14 -0400 |
Message-ID: | <f60fe000907061017w9ef1865ndc1bbe9bf46ad906@mail.gmail.com> |
Subject: | Re: Why doesn't "find .|grep aword" work? |
From: | "Mark J. Reed" <markjreed AT gmail DOT com> |
To: | cygwin AT cygwin DOT com |
X-IsSubscribed: | yes |
Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
List-Id: | <cygwin.cygwin.com> |
List-Unsubscribe: | <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com> |
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 |
On Mon, Jul 6, 2009 at 1:13 PM, km4hr wrote: > > Do pipes work in cygwin in the usual way? Pipes on Cygwin work in the usual way. You seem to misunderstand how find and grep work. > Why doesn't the following command works on HP Unix? Why not cygwin? > I get no output from this command even though I'm sure the word "hello" is > in some files. > > find .|grep "hello" That will look for files whose *name* contains "hello". The output of 'find" is a list of filenames. You then run grep on that list looking for the string "hello". If you want to instead run grep "hello" on all the files found by find, then the simplest change to your command is to introduce the xargs ("transpose arguments") utility, like this: find . | xargs grep hello However, that will fail on files with strange names, and give you errors about trying to grep directories, so what you really want is this: find . -type f -print0 | xargs -0 grep hello None of this is Cygwin-specific. It's just the way find and grep work, on all UNIXlike systems. -- Mark J. Reed <markjreed AT gmail DOT com> -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |