Recursive Grep Command – Recursively Search Through Directories

How to perform a recursive grep on Linux, allowing you to search through files / sub directories for a specific string.

How to grep recursively

grep -r SEARCHSTRING /home/*

Enter your own search in the SEARCHSTRING above…

Say for example I am searching for the string class=”author” located somewhere in /var/www/wp-content/themes/your-theme. I would type the following at the shell prompt:

grep -r class="author"   /var/www/wp-content/themes/your-theme/*

Grep will then output the string found in the file on the right and the file it’s located in on the left.


grep -r sub_rss    theme/*
theme/lib/functions/widgets.php:                   "sub_rss"

Note in the example above I am searching for the string sub_rss in the dir themes.

Article source:

Share and Enjoy

  • Facebook
  • Twitter
  • Delicious
  • LinkedIn
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS
This entry was posted in Little Guides and tagged , , . Bookmark the permalink.

Comments are closed.