Skip to content

Instantly share code, notes, and snippets.

@joshschmelzle
Last active December 15, 2016 14:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joshschmelzle/9d3368079fd4e4ace50433d7f2597d97 to your computer and use it in GitHub Desktop.
Save joshschmelzle/9d3368079fd4e4ace50433d7f2597d97 to your computer and use it in GitHub Desktop.

To look up files recursively in the given directory for the given text, and display the file name with line number that has the matching text.

grep -rHn "text to search" /path/to/dir

To use a search pattern, use the following command:

grep -rHn -e "text pattern to search" /path/to/dir

Args:

r – search recursively
H – display the file name with the matching text
n – display the line number in the file with the matching text
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment