home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  

UNIX in a Nutshell: System V Edition

UNIX in a Nutshell: System V EditionSearch this book
Previous: Reference: gprof Chapter 2
UNIX Commands
Next: Reference: groups










Search one or more files for lines that match a regular expression regexp . Regular expressions are described in Section 6. Exit status is 0 if any lines match, 1 if not, and 2 for errors. See also egrep and fgrep .



Precede each line with its block number.


Print only a count of matched lines.


Print matched lines but not filenames (inverse of -l ).


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.


Silent mode: print only error messages, and return the exit status.


Print all lines that don't match regexp .


Restrict regexp to matching a whole word (like using < and >> in vi).


List the number of users who use the C shell:

grep -c /bin/csh /etc/passwd

List header files that have at least one #include directive:

grep -l '^#include' /usr/include/*

List files that don't contain pattern :

grep -c 




 | grep :0

Previous: Reference: gprof UNIX in a Nutshell: System V Edition Next: Reference: groups
Reference: gprof Book Index Reference: groups

The UNIX CD Bookshelf Navigation The UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System