# Search a fixed word or sentence (substring) in a file
fgrep "word or sentence" path/to/file
fgrep "importat" production.log
# Search some pattern in a file
grep "pattern" path/to/file
grep "alias= b.*" ~/.bashrc
# Search on a gz and zip files
zgrep "pattern" path/to/file.gz
zipgrep "pattern" path/to/file.zip
# Show context lines after and before the matches; works for all grep commands
grep "pattern" -A<after-lines> -B<before-lines> path/to/file
grep "invoices/" -A3 -B1 log/production.log
# Search in a folder (to show all matches, omit -l parameter); works for all grep commands
grep -rl "pattern" path/to/folder
grep -rl "my-secret-password" /home/user