Grep cheatsheet

Shortcuts

OR

$ cat file.txt | grep 'hello\|world' # searches for 'hello' or 'world'

AND

$ cat file.txt | grep 'hello' | grep 'world' # and using pipe operation

$ cat file.txt | grep -E 'hello.*world'

NOT

$ cat file.txt | grep -v 'hello' # search for all patterns that do not have 'hello'

Ignore case

$ cat file.txt  | grep -i 'blah' # search for blah in any casing format