Skip to content

Instantly share code, notes, and snippets.

@jvns

jvns/grep.txt Secret

Last active February 20, 2026 20:58
Show Gist options
  • Select an option

  • Save jvns/9f5966633875a4758e0d947a5b4dbdcf to your computer and use it in GitHub Desktop.

Select an option

Save jvns/9f5966633875a4758e0d947a5b4dbdcf to your computer and use it in GitHub Desktop.
--help Print help
--version -V Print version information
DISPLAY:
--only-matching -o Only print matching part
--line-number -n Display line number before each line
--files-with-matches -l Print only filenames with matches
--files-without-match -L Print only filenames without matches
--after-context=num -A Print trailing context
--before-context-num -B Print leading context
--context-num -C Print trailing and leading context
--color=when Whether to use color (never/always/auto)
-H Always print filename
-h Never print filename
--byte-offset -b Display byte offset
--count -c Only display count of matches
--quiet, --silent -q Don't print output
--no-messages -s Don't print error messages for unreadable files
--null Print a zero byte after the file name.
--label Label to use in place of "(standard input)"
HOW TO MATCH:
--ignore-case -i Case insensitive match
--invert-match -v Invert pattern match
--extended-regexp -E Treat pattern as extended regexp
--fixed-strings -F Treat pattern as a string, not a regexp
--basic-regexp -G Treat pattern as basic regexp
--file=file -f Read patterns from file
--regexp=pattern -e Specify multiple patterns, like '-e p1 -e p2'
--word-regexp, -w Only match if word matches regexp
--line-regexp Only match if line matches regexp
WHICH FILES TO SEARCH:
--recursive, -R, -r Recursively search subdirectories
--text -a Treat all files as ASCII
--directories=action -d How to treat directories (read/recurse/skip)
--devices=action -D How to treat devices (read/recurse/skip)
--exclude pattern Exclude files matching pattern
--include pattern Include only files matching pattern
--exclude-dir pattern Exclude directories matching pattern
--include-dir pattern Include only dirs matching pattern
-O Follow explicitly listed symlinks
-P Don't follow symlinks
-S Follow symlinks
-I Ignore binary files
--binary -U Don't print binary files
--binary-files=value How to handle binary files
MISC
--bz2decompress -J Decompress with bzip2 first
--lzma -M Decompress with lzma first
--xz -X Decompress with xz first
--decompress -Z Decompress with gunzip first
--max-count num -m Stop reading the file after num matches
--mmap Use mmap for performance
--null-data -z Use zero byte instead of newline for input/output
--line-buffered Force output to be line buffered
-y Obsolete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment