Posted on 15 Dec, 2021
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