?
Solved

How to find a word in all files under / ?

Posted on 2004-04-13
4
Medium Priority
?
528 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 21

Accepted Solution

by:
tfewster earned 400 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

A metadevice consists of one or more devices (slices). It can be expanded by adding slices. Then, it can be grown to fill a larger space while the file system is in use. However, not all UNIX file systems (UFS) can be expanded this way. The conca…
Every server (virtual or physical) needs a console: and the console can be provided through hardware directly connected, software for remote connections, local connections, through a KVM, etc. This document explains the different types of consol…
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.:
Suggested Courses
Course of the Month16 days, 1 hour left to enroll

850 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