Solved

How to find a word in all files under / ?

Posted on 2004-04-13
4
504 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

In tuning file systems on the Solaris Operating System, changing some parameters of a file system usually destroys the data on it. For instance, changing the cache segment block size in the volume of a T3 requires that you delete the existing volu…
Java performance on Solaris - Managing CPUs There are various resource controls in operating system which directly/indirectly influence the performance of application. one of the most important resource controls is "CPU".   In a multithreaded…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

803 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