GREP(1) GREP(1) grep -- , grep [...] [...] grep [...] -e ... [...] grep [...] -f _ ... [...] grep . - , , grep , . , grep , . "-" . , , . --help . -V, --version grep. -E, --extended-regexp (ERE, . ). -F, --fixed-strings , . -G, --basic-regexp (BRE, . ). . -P, --perl-regexp Perl- (PCRE). -z (--null-data), grep -P . -e PATTERNS, --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[=] () , , , , , ( ) escape-, . GREP_COLORS. - , 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= , , . ; , , , -z . binary, grep , . , grep - , "binary file matches". without-match, grep , , -I.. text, grep , ; -a. binary, grep -z. , binary text , . , binary, q$ might q, , , text. : -a , , . , , , -a LC_ALL='C', , . -D , --devices= , FIFO , . , read, , , . skip, . -d , --directories= , . read, , . skip, "". recurse, , , . -r. --exclude= - , , ; - , , (/) . - , ; -- . *, ? [...] \ . --exclude-from= , - , ( , --exclude). --exclude-dir= - , . - , . - . -I , ; --binary-files=without-match. --include= , ( , --exclude). -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 : "basic" (BRE), "extended" (ERE) "perl" (PCRE) (, perl). GNU grep . . ; . , Perl, pcre2syntax(3) pcre2pattern(3), PCRE. , . , , , . - , . . - . , . -- , [ ]. - . ^, - ; . , [0123456789] - . , . - , , . , C, , [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 . '; - , , ' . ' |; - , - . , , , . , . The back-reference \n , where n is a single digit, matches the substring previously matched by the nth parenthesized subexpression of the regular expression. ?, +, {, |, ( ) ; \?, \+, \{, \|, \( \). 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 ( false). . sl= SGR ( , , -v , , -v). , rv -v, . cx= SGR ( , -v , , -v). , rv -v, . ( ). rv , ( ) sl= cx=, -v. -- false ( ). 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 , (EL) (\33[K) , . , EL . , terminfo back_color_erase (bce), , EL . false ( ). , =.... ( false), , . 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-2023 Free Software Foundation, Inc. ; . ; . . An {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. , , , , . . 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 . Olex Denkin Yuri Chornoivan ; , GNU General Public License Version 3 . . , , : . GNU grep 3.11 2019-12-29 GREP(1)