grep cheatsheet
January 18, 2025 ยท View on GitHub
Will be logging here various uses-cases of grep
-
Print anything between 2 patterns
# print all function names inside a python files grep -o -P '(?<=def ).*?(?=\()' demo.py -
Ignore more than one pattern from search
# ignore json and py files from output # -v means invert-match # -E activates extended regexp patterns (egrep). Allows use of symbols like +, |, ? ls | grep -Ev '(.json|.py)' # this is same as ls | grep -v -e .json -e .py