grep is used to find strings and other features within a file
# See full grep options
> grep --help
# Example file - file.txt
Taylor Elementary
Fort St. John Elementary
Fort St. John Junior High
Fort St. John High School
Edmonton Bachelor of Science
Edmonton PhD
Scottsdale Post-Doc
Phoenix Professor
# Find lines with "Edmonton" on the line
> grep Edmonton file.txt
Edmonton Bachelor of Science
Edmonton PhD
-B, --before-context=NUM print NUM lines of leading context
-A, --after-context=NUM print NUM lines of trailing context
-C, --context=NUM print NUM lines of output context
#Find lines with "Scottsdale" on the line and print the next line
> grep -A 1 Scottsdale file.txt
Scottsdale Post-Doc
Phoenix Professor
# Find lines with "Scottsdale" on the line and print the previous line
> grep -B 1 Scottsdale file.txt
Edmonton PhD
Scottsdale Post-Doc
# Find lines with "Scottsdale" on the line and print the previous AND next line
> grep -C 1 Scottsdale file.txt
Edmonton PhD
Scottsdale Post-Doc
Phoenix Professor