Link to home
Start Free TrialLog in
Avatar of leungpingkei
leungpingkei

asked on

How to find a word in all files under / ?

Dear all expert,

How can I find a word in all files under / ? Please be informed that it contains files or folders under /  so "more /* | grep (word)" is not workable.

Thanks

Gary
Avatar of brettmjohnson
brettmjohnson
Flag of United States of America image

If you are using gnu grep, use the -r switch to recursively search.
      grep -r word /*

Otherwise use find:
      find / -type f | xargs grep word

If you don't have xargs, use find -exec
      find / -type f -exec grep word {} \;


      
ASKER CERTIFIED SOLUTION
Avatar of tfewster
tfewster
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of glassd
glassd

grep -l will give the file name instead of the matched lines.
Avatar of leungpingkei

ASKER

Thanks for all your information.