Skip to content

Instantly share code, notes, and snippets.

@acbrent25
Created March 19, 2018 18:39
Show Gist options
  • Save acbrent25/9afc90a6d59d17b846e939a2ce56425e to your computer and use it in GitHub Desktop.
Save acbrent25/9afc90a6d59d17b846e939a2ce56425e to your computer and use it in GitHub Desktop.
[Mac Terminal Commands] Grep commands to search anything #grep
Text in subfolders -r grep -r Walden ~/Documents/*
Finds Walden in any file in any subfolder of ~/Documents.
Whole words only -w grep -w live
Finds only live ; does not find liver , lives , lived , and so on.
Case-insensitive text -i grep -i pond
Finds pond , POND , or Pond .
File names only -l grep -l Walden
Finds files containing Walden , but returns only a list of file names.
Number of occurrences only -c grep -c Walden
Returns the names of files containing Walden and the number of hits in each file.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment