cancel
Showing results for 
Search instead for 
Did you mean: 

grep and find

SOLVED
Go to solution
Jessica Chou
Advisor

grep and find

Hi!
How do I look for a pattern from a directory and its sub dir?

Thankx
Jessica

PS:
find -type file | xargs grep

works fine on HP but not on Linux.
5 REPLIES
Jessica Chou
Advisor

Re: grep and find

Sorry, a typo in my previous mail.
the command i type should be

find -type f | xargs grep

(but not "file" after -type"

Jessica
Frank Reifenstahl
Occasional Visitor

Re: grep and find

Hi Jessica,

I tried - and it works! What's your problem? Any error messages?

Bye
Frank
Dave Kelly_1
Respected Contributor

Re: grep and find

Try

find /directory -type file -exec grep -i {} ;
Dave Kelly_1
Respected Contributor
Solution

Re: grep and find

Apologies for previous post (problems with missing slashes)

Try

find /directory -type file -exec grep -i {} \;
Jessica Chou
Advisor

Re: grep and find

Hi!
find ./dir1 -type f -exec grep -i test1 {} ;

works fine. Thank you.

Jessica
PS: On Linux
find ./dir1 -type f | xargs grep test1
gave me the error message as:
grep: invalid option -- .
Usage: grep [OPTION]... PATTERN [FILE]...
Try `grep --help' for more information.