Find files containing a text string in subfolders using ‘grep’ in Ubuntu 12.04

How to find files containing a particular text string in current folder & subfolders using the ‘grep’ command from an Ubuntu 12.04 command-line terminal.

 Posted February 27, 2016

Go to the folder you want to search in using cd:

For a simple list of files containing the example string “tags”:

Output:

 

To see each line containing the example string “tags”:

Output:

 

As above, but with line numbers after the filenames:

Output:

 

To search whole computer/server using sudo, using the above options:

 

Leave a Reply

Your email address will not be published. Required fields are marked *