Skip to content

Instantly share code, notes, and snippets.

@asears
Created September 30, 2021 14:05
Show Gist options
  • Select an option

  • Save asears/a38f2de76ad5f8c2ed2eecafbad69f14 to your computer and use it in GitHub Desktop.

Select an option

Save asears/a38f2de76ad5f8c2ed2eecafbad69f14 to your computer and use it in GitHub Desktop.
Grep examples

Grep

. Find text only in specific file types/extensions – Returns all the search results

grep -ir --include=\*.py text_to_search
  1. If you want to only see the file names, then add the -l filter
grep -ilr --include=\*.py text_to_search
  1. Based on the results, if you notice that there are certain files/folders that you’d like to ignore, you can add a -v option to exclude certain texts on the piped results, and you can add multiple of those at the same time
grep -ilr --include=\*.py text_to_search | grep -v "text_to_ignore1" | grep -v "text_to_ignore2" | more
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment