My grep commands

When I search for things in my codebase I find that using the terminal and grep is usually the best option. Here is what I usually run:

# find meng in all files under a specific directory

# switches i - case insensitive, r - recurrsive, H - show file and path, n - line number
grep -irHn 'meng' current/

# you can count using c
grep -irc 'meng' current/

# you can use regex
grep -ire ^d current/
# search files in current direct for any line that starts with d or D
# make sure e is an the end for example I want line numbers
grep -irne ^d current/

# to skip binary files use I (uppercase i)
grep -iIHrn 'meng' current/

 

Leave a Reply

Your email address will not be published. Required fields are marked *