Skip to content

Instantly share code, notes, and snippets.

@joellobo
Last active September 20, 2019 12:57
Show Gist options
  • Save joellobo/c6f8069c21733f407574ce9cf6ae4afc to your computer and use it in GitHub Desktop.
Save joellobo/c6f8069c21733f407574ce9cf6ae4afc to your computer and use it in GitHub Desktop.
Linux - grep
systemd-analyze blame
1. Grep OR Using \|
grep 'pattern1\|pattern2' filename
2. Grep OR Using -E
grep -E 'pattern1|pattern2' filename
3. Grep OR Using egrep
egrep 'pattern1|pattern2' filename
4. Grep OR Using grep -e
grep -e pattern1 -e pattern2 filename
5. Grep AND using -E ‘pattern1.*pattern2’
grep -E 'pattern1.*pattern2' filename
grep -E 'pattern1.*pattern2|pattern2.*pattern1' filename
6. Grep AND using Multiple grep command
grep -E 'pattern1' filename | grep -E 'pattern2'
7. Grep NOT using grep -v
grep -v 'pattern1' filename
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment