3.6. grep with Options

The grep command has a number of options that control its behavior. Not all versions of UNIX support exactly the same options, so be sure to check your man pages for a complete list. The Gnu version of grep added a number of new options and alternative ways to use the options, shown in Table 3.6. The Gnu grep options work with all the different variants of grep, including grep -G, -E, and -F, as shown in Table 3.7.

Table 3.6. Gnu grep Options
Option What It Does
-b Precedes each line by the block number on which it was found. This is sometimes useful in locating disk block numbers by context.
-c Displays a count of matching lines rather than displaying the lines that match.
-h Does not display filenames.
-i Ignores the ...

Get Linux Shells by Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.