fastest way to search for strings
Is there a faster way to search for a file containing a given string than using grep -re "string" /
This takes a long time to search through the entire system, so I was wondering if there is a faster way. I don't know the name of the file, just that it will contain a given string. Thanks! |
Look at the find command (info find) and the locate command (info locate). The locate is faster since it uses the data base of file names and locations so it doesn't have to read the drive for file names. On the other hand, find lets you filter the files by type, so you could limit the searching to files that, for example, are not executable or that were in system directories.
In fact, running grep -ar <expession> / may cause an infinite wait since it will eventually search /dev/null or /dev/random, and those (pseudo) files are infinitely long. |
Quote:
|
grep searches the contents of a file. Try typing man grep
Quote:
|
There is a program called Ack and it's design to do fast searches on large content files.
I heard about this program on http://fosscasts.com/screencasts Scroll down to episode #15 Power Searching with Ack and and watch the video tutorial on its usages. -Cheers |
All times are GMT -5. The time now is 09:23 AM. |