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: Subject: Re: Why doesn't "find .|grep aword" work? From: "Mark J. Reed" To: cygwin AT cygwin DOT com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: 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 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 -- 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