fgrep—search a file for a character string

fgrep [ –bchilnsvx ] [ –e special string ]
[ –f filename ] [ strings ] [ filename…]

fgrep (fast grep) searches files for a character string and prints all lines that contain that string. fgrep is different from grep(1) and egrep(1) because it interprets regular expression metacharacters as literals. (See grep and grep -F in Chapter 3.)

Example A.25.
1   fgrep '***' *
2   fgrep '[ ] * ? $' filex
				

Explanation

  1. Displays any line containing three asterisks from each file in the present directory. All characters are treated as themselves; i.e., metacharacters are not special.

  2. Displays any lines in filex containing the string enclosed in quotes.

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.