Learn GNU/Linux Commands (15): Search Content - grep

The program "grep" search the content of files. But default, it gets the input from standard input. But it can also read the content of files. With piping, "grep" is often used to search other programs' output.


grep PATTERN [FILE]...

Search for the regular expression PATTERN in each FILE and print the matching lines by default. A FILE of “-” stands for standard input. If no FILE is given, recursive searches examine the working directory, and nonrecursive searches read standard input.

To end the search in standard input, press CTRL+D for EOF (end of file) or CTRL+C.

By default, "grep" is case sensitive.

"grep" options:

  • -i, --ignore-case: case insensitive.
  • -v, --invert-match: select lines that don't match.
  • -r, --recursive: read all files under each directory, recursively, following symbolic links only if they are on the command line. Note that if no file operand is given, grep searches the working directory.

Search for Multiple Patterns

To match lines that match multiple patterns simultaneously, use "grep" again with piping.

grep PATTERN1 [FILE]... | grep PATTERN2 | grep PATTERN3 ...




Intel 7th and 8th generation processor graphics driver for Windows 7/8/8.1

AV1 vs VP9 vs AVC (h.264) vs HEVC (h.265): Part II - Fidelity

AV1 vs VP9 vs AVC (h.264) vs HEVC (h.265): Part I - Lossless

OBS Studio settings for best quality (loseless) recording

AV1 vs VP9 vs AVC (h.264) vs HEVC (h.265): Part IV - Decode

AV1 vs VP9 vs AVC (h.264) vs HEVC (h.265): Part III - Quality

YouTube starts delivering videos in AV1 format