List all files containing a string from Terminal
Jan 5, 2019
1 minute read

Sometimes you may find it very useful to find any files containing a string. While most code editors provide this features when you add a folder as a project, you may be just navigating inside your terminal and need a quicker way to achieve that.

The grep is a very powerful command for search patterns, and is available by default in most of Linux distro’s and also Mac.

You may try, for example:

grep -Ril "string you're looking for here" /path/to/dir

Going deeper into the params, we’re passing -Ril, where R means recursion (find in all subdirectories), i means make it case insensitive, and l make it returns only the name of the file, not the content of it, making it more visible to read in your Terminal output.

You can always find the complete list of options available running man grep.