GREP(1) GREP(1) grep - grep []... []... grep []... -e ... []... grep []... -f _ ... []... grep . -e -f grep . grep . "-" . . --help . -V -- grep . -E --extended-regexp (EREs ). -F --fixed-strings . -G --basic-regexp (BREs ). . -P --perl-regexp (PCREs). -z (--null-data) grep -P . -e --regexp= . -f (--file) . "-". -f --file= . -e (--regexp) . . - . -i --ignore-case . --no-ignore-case . . -i . -v --invert-match . -w --word-regexp . . . . -x . -x --line-regexp . ^ $. -c --count . -v --invert-match ( ) . --color[=] --colour[=] ( ) ( ) . GREP_COLORS. never () always () auto (). -L --files-without-match . -l --files-with-matches . . -m --max-count= . grep . -1 grep . grep . . grep . -c --count grep . -v --invert-match grep . -o --only-matching ( ) . -q --quiet --silent . . -s --no-messages. -s --no-messages . -b --byte-offset ( 0) . -o (--only-matching) . -H --with-filename . . GNU. -h --no-filename . ( ) . --label= . : gzip -cd foo.gz | grep --label=foo -H ' '. -H. -n --line-number ( 1) . -T --initial-tab . : -H -n -b. ( ) . -Z --null ( ASCII NUL) . grep -lZ . . find -print0 perl -0 sort -z xargs -0 . -A --after-context= . (--) . -o --only-matching . -B --before-context= . (--) . -o --only-matching . -C - --context= . (--) . -o --only-matching . --group-separator= -A -B -C -- . --no-group-separator -A -B -C . -a --text --binary-files=text. --binary-files= . (null) -z. binary () grep . grep . without-match ( ) grep -I. text () grep -a. binary grep -z. binary text . binary q$ q text. binary . () . : -a . -a LC_ALL='C' . -D --devices= FIFO . read () . skip () . -d --directories= . read . skip . recurse . -r. --exclude=GLOB GLOB (/) . GLOB . * ? [...] \ . --exclude-from=FILE FILE ( --exclude). --exclude-dir=GLOB GLOB. GLOB. GLOB. -I --binary-files=without-match. --include=GLOB GLOB ( --exclude). --include --exclude . --include --exclude --include. -r, --recursive . grep . -d recurse. -R, --dereference-recursive . -r. --line-buffered . . -U, --binary ( ) . MS-DOS MS-Windows grep --binary-files. grep CR ( ^ $ ). -U CR/LF . MS-DOS MS-Windows. -z, --null-data ( ASCII NUL) . -Z --null sort -z . . . grep : <<>> (BRE) <<>> (ERE) <<>> (PCRE). grep GNU . . . pcre2syntax(3) pcre2pattern(3) PCRE. . . (meta-character) . . . . [ ]. . ^ . [0123456789] . . C ASCII . [a-d] [abcd]. : [a-d] [abcd] [aBbCcDd] . C LC_ALL C. . : [:alnum:] [:alpha:] [:blank:] [:cntrl:] [:digit:] [:graph:] [:lower:] [:print:] [:punct:] [:space:] [:upper:] [:xdigit:]. [[:alnum:]] . C ASCII [0-9A-Za-z]. ( ). . ] . ^ . - . ^ $ . \< \> . \b \B . \w [_[:alnum:]] \W [^_[:alnum:]]. : ? . * . + . {n} n . {n,} n . {,m} m . GNU. {n,m} n m. . |; . . . \n n n . ?, +, {, |, (, ) \?, \+, \{, \|, \(, \). 0 1 2 . -q --quiet --silent 0 . grep . LC_foo LC_ALL LC_foo LANG . . LC_ALL LC_MESSAGES pt_BR LC_MESSAGES. C grep (NLS). locale -a . GREP_COLORS --color . ms=01;31:mc=01;31:sl=:cx=:fn=35:ln=32:bn=32:se=36 rv ne ( ). . sl= SGR ( -v -v). rv -v . ( ). cx= SGR ( -v -v). rv -v . ( ). rv () sl= cx= -v. ( ). mt=01;31 SGR ( -v -v). ms= mc= . . ms=01;31 SGR . ( -v). sl= ( cx= rv) . . mc=01;31 SGR . ( -v). cx= ( sl= rv) . . fn=35 SGR . . ln=32 SGR . . bn=32 SGR . . se=36 SGR (:) (-) (--). . ne Erase in Line (EL) (\33[K) . EL. terminfo back_color_erase (bce) EL . ( ). =.... ( ) . Select Graphic Rendition (SGR) . . grep SGR (\33[...m). 1 4 5 7 39 30 37 90 97 16 38;5;0 38;5;255 88 256 49 40 47 100 107 16 48;5;0 48;5;255 88 256 . LC_ALL, LC_COLLATE, LANG LC_COLLATE [a-z]. LC_ALL, LC_CTYPE, LANG LC_CTYPE . UTF-8 ASCII . C POSIX . LC_ALL, LC_MESSAGES, LANG LC_MESSAGES grep . C . POSIXLY_CORRECT grep POSIX grep GNU . POSIX . POSIX << >> << >>. . 1998-2000 2002 2005-2025 . . . . {n,m} grep . grep. . "f" ".c" "g" ".h". -n -- "*g*.h" "-" /dev/null "*g*.h". $ grep -n -- 'f.*\.c$' *g*.h /dev/null argmatch.h:1:/* definitions and prototypes for argmatch.c 1 argmatch.h. (globbing) . awk(1), cmp(1), diff(1), find(1), perl(1), sed(1), sort(1), xargs(1), read(2), pcre2(3), pcre2syntax(3), pcre2pattern(3), terminfo(5), glob(7), regex(7) info grep info grep . 3 . . : . GNU grep 3.12- 2025-03-21 GREP(1)