Find all files containing specific text on Linux and Mac

This post introduces how to find all files containing some text on Linux and Mac.

Step 1: cd to the folder where you would like to start with the search.

Step 2: use the following command:

$ grep -Ril "text-to-find-here" ./

Then the file names containing the text you would like to search will be listed.

  • R — stands for recursive.
  • i —  ignore case (optional in your case).
  • l — stands for “show the file name, not the result itself”.

For more commonly used Linux commands, check my other posts at here  and here .

Leave a Reply

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