That is why I love linux. Linux gives you fine grain control over your system with easy but very useful commands, searching text in files with so much control over output is not such an easy task in other operating systems but in linux its like a butter cake.

To find a text in all directories

grep -r 'txttosearch' dirname/ 
  • grep : It matches the text or expression
  • -r : It is a switch to find recursively in all directories
  • txttosearch : It is text to be searched in files
  • dirname/ : It is the base directory from where it will start search

You can save search output to file as well

grep -r 'txttosearch' dirname/ > search.log

wasn’t that so easy? šŸ™‚