Title: Grep Options
Course: CIS 121: Linux/UNIX I: Fundamentals ~ For IGNITE Review > Section: Learning Modules

The grep command is used to select lines that have a certain pattern or set of patterns.

- The syntax is: grep <pattern> <file(s)> or some_command | grep <pattern>.
  - Example: grep help_me file1
  - This will display all lines in file1 that have the pattern “help_me”.
- The “pattern” is what is being searched for.
- The “pattern” is a limited regular expression.

Grep Options

-i: Ignore case

-l: List file names only if there is a match

-w: Treat pattern as a standalone word (cannot be embedded)

-c: Report count of lines with a match (not total number of matches)

-n: Report line numbers when listing matches