yet another stupid unix question

nageov3t

Lifer
Feb 18, 2004
42,808
83
91
I feel like I should know this, but how can I search through every single file on an entire unix machine looking for any file with a specific string of text in it?
 

Red Squirrel

No Lifer
May 24, 2003
70,612
13,816
126
www.anyf.ca
Code:
grep -ri "string" /folder

Should work. There's other options too like showing lines before/after etc.. r = recursive i = case insensitive.

You can put just / instead of folder if you want to search the entire system. Keep in mind that will also search all mounted drives.
 

Brazen

Diamond Member
Jul 14, 2000
4,259
0
0
You can put just / instead of folder if you want to search the entire system. Keep in mind that will also search all mounted drives.

If you do a recursive search on root, you might want to add "--devices=skip" or "-d skip".
 

JD50

Lifer
Sep 4, 2005
11,918
2,883
136
You could also use find with either -exec or xargs. Something like "find / -name "*" | xargs grep "string"

The syntax might be a little off, but it's something like that. The "find" man page should help you tune that command a little bit.