I'd like to search the entire server by content. (text file)
When I try grep -rl "text here", it freezes.
How would you do it?
And how long does it usually take?
You need to specify a file when using the grep
command. With the command you're using, you're searching in the standard input...
Try grep -r "test" directory
.
find / -name "*.txt" -exec grep "text here" {} \; -print 2>/dev/null
Which can be explained in human speak as:
you forget to specify what sort of files you want to search,
make sure you log in as root
cd /
grep -rl "text here" * > /tmp/match.txt
this going to take a very long time, and you can collect the results later by checking /tmp/match.txt
The following command searches all the files ending with .txt in the the current working directory and all subdirectories:
find . -type f -name '*.txt' -exec grep -Hn "text here" {} \;