Syntax
grep [OPTION...] PATTERNS [FILE...]
grep [OPTION...] -e PATTERNS ... [FILE...]
grep [OPTION...] -f PATTERN_FILE ... [FILE...]
The grep
command takes in text from stdin or a file.
Quick Examples
example.txt
The lady with the dog
is sitting beside a lake
eating her honey lemon cake
looking at her son Jake
# Read from a file
$ grep ake example.txt
# Output
is sitting beside a lake
eating her honey lemon cake
looking at her son Jake
# Read from stdin (piping)
$ printf "The lady with the dog\nis sitting beside a lake\neating her honey lemon cake\looking at her son Jake" | grep ake
# OR
$ cat example.txt | grep ake
# Output
is sitting beside a lake
eating her honey lemon cake
looking at her son Jake