Why doesn't "find .|grep aword" work?

Thrall, Bryan bryan.thrall@flightsafety.com
Mon Jul 6 17:19:00 GMT 2009


km4hr wrote on Monday, July 06, 2009 12:13 PM:
> Do pipes work in cygwin in the usual way?
> 
> Why doesn't the following command works on HP Unix? Why not cygwin?
> 
> find .|grep "hello"
> 
> I get no output from this command even though I'm sure the word
"hello" is
> in some files.
> 
> What I want this command to do is find all files in all
sub-directories and
> pipe the output to grep. Grep then looks in each file for the word
"hello".
> The names of files that contain the word "hello" should be returned.
> 
> thanks.

Your command has grep search the list of files for "hello", not the
contents of those files.

Try this:

find . | xargs grep "hello"

This is not a Cygwin-specific question, BTW.

HTH,
-- 
Bryan Thrall
FlightSafety International
bryan.thrall@flightsafety.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



More information about the Cygwin mailing list