Simpler Navigation for Servers and Operating Systems - Please Update Your Bookmarks
Completed: a much simpler Servers and Operating Systems section of the Community. We combined many of the older boards, so you won't have to click through so many levels to get at the information you need. Check the consolidated boards here as many sub-forums are now single boards.
If you have bookmarked forums or discussion boards in Servers and Operating Systems, we suggest you check and update them as needed.
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.