Организация UNIX-систем и ОС Solaris


for the description of the

See largefile(5) for the description of the behavior of grep when

encountering files greater than or equal to 2 Gbyte ( 2 **31 bytes).


Example 1: Finding all uses of a word

To find all uses of the word "Posix" (in any case) in the file,

and write with line numbers:

example% /usr/bin/grep -i -n posix

Example 2: Finding all empty lines

To find all empty lines in the standard input:

example% /usr/bin/grep ^$


example% /usr/bin/grep -v .

Example 3: Finding lines containing strings

Both of the following commands print all lines containing strings abc or def or both:

example% /usr/xpg4/bin/grep -E `abc def'

example% /usr/xpg4/bin/grep -F `abc def'

Example 4: Finding lines with matching strings

Both of the following commands print all lines matching exactly abc or def:

example% /usr/xpg4/bin/grep -E `^abc$ ^def$'

example% /usr/xpg4/bin/grep -F -x `abc def'

Environment Variables

See environ(5) for descriptions of the following environment

variables that affect the execution of grep: LC_COLLATE, LC_CTYPE,


Exit Status

The following exit values are returned:


One or more matches were found.


No matches were found.


Syntax errors or inaccessible files (even if matches were found).

See Also

egrep(1) , fgrep(1) , sed(1) , sh(1) , attributes(5) , environ(5) ,

largefile(5) , regex(5) , regexp(5) , XPG4(5)



Lines are limited only by the size of the available virtual memory.

If there is a line with embedded nulls, grep will only match up to

the first null; if it matches, it will print the entire line.


The results are unspecified if input files contain lines longer than

LINE_MAX bytes or contain binary data. LINE_MAX is defined in


Содержание  Назад  Вперед