Welcome to TagMyCode

Please login or create account to add a snippet.
Language: Bash
Posted by: Mr. Zick
Added: Jul 18, 2012 4:06 AM
Views: 1771
Tags: no tags
  1. To quickly find any text string within any text file, try this from a terminal window:
  3. grep -l  [text to find] [files to look in]
  5. For example, grep -l 123abc *.html will list the name of any file in the current directory that ends in .html and contains the string 123abc.
  7. (That's a lower-case-L following the GREP)
  9. Quite powerful, and fairly fast. Now, if you have some spare time, and want to see what it can really do, try this:
  10. su root
  11. cd /
  12. grep -lr "text to find" *
  13. This will tell the OS to find the "text to find" in every file in every directory, all the way down through the tree. The -r flag tells grep to recursively search directories.
  15. Of course, OS X has something like 26,000 files, so this can take a very long time!