• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Finding a certain string in a file

Ace69

Senior member
This is my latest tangent that I have been on. I have a string such as "test". I don't know what file this string exists in, so I want to be able to search ALL files under /. How would I do this? I thought about find /*|grep "test", but that just finds the files that have "test" in them. I want to be able to cat all files under root. Any ideas?
 


<< Would "." or ".." help in the string or "/ .."? I'm not a UNIX expert but just a guess for ya. >>


That would just specify the current and parent directories. No go on that one. 🙂
 
fgrep will let you search the contents of a single file, I dunno how you would get it to search directories tho 🙁

[edit]

using egrep will let you search multiple files, example would be:

egrep -l 'hello' file1 file2

this searchs the two files for the pattern 'hello' and prints out what files it finds hello in. Hope this helps some.
 
Sweet, djs1w. Thanks! It worked! I just did a "grep -r test /" and it worked flawlessly. Just another example of how you can do any file manipulation in the *nixs' 🙂
 
Back
Top