Fast, Recursive And Literal Search Across All Files In A Folder (Grep / Find)

I’ll just put here for future reference:

This grep will search recursively across all files in a given path.

grep -HrnIFi --color=always searchterm .

Notes:

  • Replace the dot at the end with the top-folder to search in.
  • Remove the lower case ‘i’ to make the search case-sensitive.
  • Remove F if searchterm is a regular expression.

Shout-out: How to use “grep” command to find text including subdirectories

To run a search only for folder or file name, use the following.

Only folder names:

find . -type d -name scripts

Only file names:

find . -type f -name scripts

Learn more about the find command on Wikipedia.