Search one or more files
for lines that match a regular expression regexp
. Regular expressions are described in Chapter 6
. Exit status is 0 if any lines match, 1 if not, and 2 for errors. See also egrep
Precede each line with its block number. (Not terribly useful.)
Print only a count of matched lines.
Use this if pat
. Solaris: this option is only available in /usr/xpg4/bin/grep
, not /usr/bin/grep
. It is common, though, on many modern Unix systems.
Print matched lines but not filenames (inverse of
Ignore uppercase and lowercase distinctions.
List filenames but not matched lines.
Print lines and their line numbers.
Suppress error messages for nonexistent or unreadable files.
Print all lines that don't
to matching a whole word (like using
). Not on SVR4, but common on many commercial Unix systems.
List the number of users who use the C shell:
grep -c /bin/csh /etc/passwd
List header files that have at least one
grep -l '^#include' /usr/include/*
List files that don't contain pattern
| grep :0