Solved

How to find a word in all files under / ?

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Let's say you need to move the data of a file system from one partition to another. This generally involves dismounting the file system, backing it up to tapes, and restoring it to a new partition. You may also copy the file system from one place to…
This tech tip describes how to install the Solaris Operating System from a tape backup that was created using the Solaris flash archive utility. I have used this procedure on the Solaris 8 and 9 OS, and it shoudl also work well on the Solaris 10 rel…
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…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

758 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

19 Experts available now in Live!

Get 1:1 Help Now