Find All Files Containing 'anything' in Linux

Below is an example of a somewhat more advanced use of the Linux find command that allows one to search the current directory (and all sub-directories) for files containing a particular string.

This is a quick way to search through files if you can't quite remember where you left something. This also can be adapted for other powerful uses that I'll leave up to the reader to figure out. Without further ado try typing the following command in to a Linux terminal:

find . -type f -exec grep -H 'anything' {} \;

Breakdown

In plain English, the above command says, find all files in the current directory and all sub-directories (find . -type f). Then execute the grep command to search for the string 'anything' within all the files returned by the find command (-exec grep -H 'anything' {}).

This example uses the string 'anything', but you can replace this with your own keywords or regular expressions.

Now you know how to do a keyword search from the Linux command line!

» More find command examples