Let’s look some practical examples of the grep command. -v – with this option, we are shown the lines that do not match the pattern we have looked for.-n – search for lines and find the receive only the matched numbers of the text lines.-r – enables recursive search in the current directory.-c – it will show only the number of lines that match the pattern searched.That is, if you want to search for the word “car” it will be the same as “CAR” -i – the search won’t be case sensitive.However, the most important and commonly used options are the: You can see the documentation and explanations of various options by executing this command in the command line: grep –helpĪs you can see there are many possibilities that the command offers us. – the file you’re performing the search in.The grep command syntax when searching for a single file looks like this: grep pattern ssh you’re running Linux on your computer, just open a terminal.
#MAC GREP COMMAND HOW TO#
Here’s an article that shows how to do it using PuTTY SSH. In other words, with grep you can search for a word or pattern and the line or lines that have it will be printed.Īt first sight, it can be a command of little utility, however, sysadmins that handle many services with various configuration files, use it to query or search for specific lines within those files.įirst, connect to the VPS using SSH. It looks in a text file for a pattern that we define. The grep command belonging to the Unix family is one of the most versatile and useful tools available.