Full-Text Search in Multiple Directories Using Grep

loading views

I am having around ~200 project directories in my ~/Developer directory and sometimes I remember that I have written some function or feature, but can't remember for which project it was. Luckily it's super easy to do a full-text search using the command line tool grep.

grep -r -I --exclude-dir=node_modules getStreak futureland*

Let me break it down:

  • -r Recursively search subdirectories listed
  • -I Ignores binary files, which improves performance. They are not important for my search anyways.
  • --exclude-dir=node_modules Excludes node_modules directories as what I am looking for cannot be found in it.
  • getStreak the text/string I am looking for
  • futureland* will search in all directories and their children that start with futureland