Skip to content

Glossary: Command Line for IT: Bash and PowerShell

grep

Also written: grep -c, grep -v, grep -n, grep -m, grep -A, grep -B, grep -w, grep -i, grep -q, grep -x

Prints the lines of a file that match a pattern. Its options count matches (-c), invert the match (-v), number the lines (-n), stop after N matches (-m), add lines before or after each match (-B, -A), match whole words (-w) or whole lines (-x), or stay quiet and just set the exit code (-q).

Where the book teaches it

Related terms

grep -Egrep -oSelect-Stringzgrep