# Created on savesnippets.com · https://savesnippets.com/U4y7ejm9UdbpHz # Lines matching either of two patterns grep -E "(ERROR|FATAL)" /var/log/app.log # Inverse: lines NOT matching grep -v "DEBUG" /var/log/app.log # Case-insensitive search with line numbers and 2 lines of context grep -inB2 -A2 "stripe" /var/log/app.log # Match a regex with groups (use -o to print only the match) grep -oE 'user_id=[0-9]+' /var/log/app.log | sort -u # Use ripgrep (rg) — faster and respects .gitignore by default rg "ERROR" --type=log -C 2