PDA

View Full Version : Bash Script Help!



oxsyn
March 14th, 2008, 11:02 PM
I hope this is the correct plact to put this. I've been playing with the CLI, trying to learn the ins & outs. I can't seem to get the following command to work correctly:


grep 'f4rr4r' /* 1>found.log 2>/dev/null &

I'm trying to search entire disk (in the background) for all files that contain my username (I know there are several on the filesystem). I want to write the results to a file "found.log" and throw out the errors.

However, the process completes instantly & the found.log file is empty.
Any ideas? Thanks!

Zwack
March 14th, 2008, 11:09 PM
grep is not by itself recursive. So your search is only searching /*

try


grep -R 'f4rr4r' /


If you only want the file names it was found in try grep -lR and if you want it case insensitive try grep -lRi ...

Z.

oxsyn
March 14th, 2008, 11:16 PM
Ah, thank you. :)

mssever
March 15th, 2008, 02:43 AM
The find command is intended for this purpose:
find / -name '*f4rr4r' There are a lot of options to customize the behavior and output.

WW
March 15th, 2008, 03:19 AM
The find command is intended for this purpose:
find / -name '*f4rr4r'

That command will look for f4rr4r in the file names. If I understood the original poster correctly, he wants to search the contents of all the files.

mssever
March 15th, 2008, 04:57 AM
That command will look for f4rr4r in the file names. If I understood the original poster correctly, he wants to search the contents of all the files.

My bad. I should have read the question a little more carefully.