Solved

How to find a word in all files under / ?

Posted on 2004-04-13
4
496 Views
Last Modified: 2010-04-21
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
0
Comment
Question by:leungpingkei
4 Comments
 
LVL 23

Expert Comment

by:brettmjohnson
ID: 10819967
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 {} \;


      
0
 
LVL 20

Accepted Solution

by:
tfewster earned 100 total points
ID: 10821136
Brettt -
find / -type f -exec grep word {} /dev/null \;
will also give you the filename  ;-)
0
 
LVL 7

Expert Comment

by:glassd
ID: 10823649
grep -l will give the file name instead of the matched lines.
0
 

Author Comment

by:leungpingkei
ID: 10824299
Thanks for all your information.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

My previous tech tip, Installing the Solaris OS From the Flash Archive On a Tape (http://www.experts-exchange.com/articles/OS/Unix/Solaris/Installing-the-Solaris-OS-From-the-Flash-Archive-on-a-Tape.html), discussed installing the Solaris Operating S…
I have been running these systems for a few years now and I am just very happy with them.   I just wanted to share the manual that I have created for upgrades and other things.  Oooh yes! FreeBSD makes me happy (as a server), no maintenance and I al…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now