Find a value or string in all files
This useful command will find all files where a given string, word, value etc is contained within the file. It will search recursively through all directories from where you are presently within the file system:
find RANGE -iname ‘RULES’ | xargs grep ‘STRING’ -GREP_ARGUMENTS
- RANGE = where you are searching. Using a . (full stop) will search all from where you presently are
- RULES = elements of a filename. For instance, ‘*.doc’ will only look through files ending in .doc - * is used as a wildcard
- STRING = the needle in the haystack that we are looking for
Typical Grep Arguments Used
- -s is the same as —no-messages. From man grep: “Suppress error messages about nonexistent or unreadable files.”
- -l, —files-with-matches. From man grep: “Suppress normal output; instead print the name of each input file from which output would normally have been printed. The scanning will stop on the first match.” Basically this just outputs the filename.
- See man grep for more
The Final Result Example (I tend to use this a lot):
find . -iname ‘*php’ | xargs grep ‘needle’ -sl
This looks for the value ‘needle’ in php files only and will only display the file names.
0 TrackBacks
Listed below are links to blogs that reference this entry: Find a value or string in all files.
TrackBack URL for this entry: http://cyberissues.eu/cgi-bin/mt-tb.cgi/17
Sands at Superior gold your investment will receive the eye is deserves. Shopping for numismatic cash and gold bullion are commodities that gives you a superb return on your investments do not hesitate to contact a crew of execs that may put you on the road to wealth vacheron constantin replica vacheron constantin replica , wedding dresses wedding dresses Superior Gold group is such a group in place whore prepared sandals fake corum watches fake corum watches fake watches fake watches