Skip to content

grep

FunctionPrints lines that match a pattern in a page or piped input (substring match).
OptionsYou can combine the options in the following table (for example -iv or -i -v).
Limitationsgrep requires a pattern and either a page path or piped input. With stdin, PATH is ignored.
OptionMeaning
-iIgnore case
-vShow lines that don’t match
-nPrefix each line with its 1-based line number (N:line)
-cPrint a count of matching lines instead of the lines
$ grep a ./page1
$ grep -i foo ./page
$ grep -n pattern ./page1
$ grep -c pattern ./page1
$ ls | grep -i page
$ ls | grep -v Draft
$ ls | grep -vn bar
$ cat ./page | grep -c error

Enter help grep in the console to view this option list. To search page bodies across a tree, use find … -exec grep.