If you tell grep to search a string in a file in a directory with or without subdirectories
and there are many, many files, it will take some time of course and it may appeared to be hung but maybe not.
I did a test run on one of my directories where it has subdirectories and many files. For example:
Code:
time grep -ir -l "How do I backup a LUKS header" backup/*
backup/docs-and-media/linux-related/cryptsetuo faq
real 2m18.305s
user 2m17.685s
I use the
time command to tell me how long it takes to the complete the search. It took
2m and 18 secs. The
-l option tells grep to list the file the string was found in. BTW, the time command is not necessary for doing grep searches, it's used here just to demonstrate that grep can take some time on searching many files. Anyway, it found the string in
backup/docs-and-media/linux-related/cryptsetuo faq
There is a another command called
ack. It's like grep on steroids and very fast.
Code:
time ack -ai -l "How do I backup a LUKS header" backup/*
backup/docs-and-media/linux-related/cryptsetuo faq
real 0m19.791s
user 0m19.265s
sys 0m0.489s
Here is the same search on the backup directory, but the search is done faster by using ack, for a total of 19secs to complete.
Give ack a try.