![]() |
grep search...
Hi,
is it possible to search with grep for a text pattern, the whole root /? something like: grep -i 'test' * or / thanks Tobias |
Hi,
I'm not sure which of the 2 you want: If you only want to check all the files in /: grep -i 'test' /* If you need to do this recursive (/ and all the subdirs): find / -type f -exec grep -i 'test' {} \; The last command is very (!!) resource unfriendly and will probably run for a while. It would be better to narrow down the field it needs to search. |
thanks druuna...
can I narrow it down with : find /home/test -type f -exec grep ... ? |
Hi,
Yes you can. There are 2 possibilities: cd /home/test find . <whatever> The . (dot) means: from the current directory. or find /home/test <whatever> The second one can be executed from any point. |
GNU grep supports the -r option, which means "recursive". It's a little less cumbersome than using find. e.g. you can grep files in sub-directories specified on the command line, e.g.
Code:
grep -r 'mypattern' /home/matthewAlso note that it might be a good idea to run the command with nice since it'll take an age anyway, and you will probably want to minimize impact on other programs as it runs. |
| All times are GMT -5. The time now is 04:40 PM. |