Skip to content

Instantly share code, notes, and snippets.

@Vladnev
Created December 26, 2017 15:04
Show Gist options
  • Save Vladnev/8bcbbba6f9575ea52117488519f2609b to your computer and use it in GitHub Desktop.
Save Vladnev/8bcbbba6f9575ea52117488519f2609b to your computer and use it in GitHub Desktop.
Grep usage
grep <pattern> <file>
grep -Hsi <pattern> <dir>
flags:
-r - recursive(include subdirs)
-l - show only filenames where was found pattern
-H - show in which file was found row
-с - count of pattern matches
-v - show only non-matches
-i - ignore case
-n - add row number to output
-s - hide errors
-w - only full word match
-C <num> - rows arround
-A <num> - row down
-B <num> - row up
-E - regex matching
patterns:
'\<word_start'
'word_end\>'
'^line_start'
'line_end$'
"word[<start>-<end>]"
"word[^<uninclude>]"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment