get a grip on grep

how to use grep on searching a text on files

I usually use this syntax with these options:

grep <text or regexp> -nrwi <path>

* -n to show line number

* -r to find also in subfolders

* -w to search the whole word only, ie. “bill” text does not find “billings”, “bills”, “bombill” 🙂

* -i case-insensitive, ie. “upload” searches “Upload”, “uPlOAd”

other useful options:

-l file names only

-c lists all the files in the path and the number of occurences of that text in each file (does not include the line where the text was found). as for my convenience, I don’t use this, kinda annoying. hehe

to search for multiple strings, just separate grep syntax with the pipe symbol

to search on the current folder, use asterisk * on path.

So who needs Netbeans as IDE when you can just use VIM, and grep all the way. 🙂

Leave A Comment

Please be polite. We appreciate that. Your email address will not be published and required fields are marked