top of page

Posts

An Easy Way To Remember grep Options With Its Original Word

Updated: Apr 29, 2022



grep is a great command on Linux and you have numerous chances to use the command when you use Linux. However, grep has lots of options that can be confusing and hard to remember unless you use them on daily basis.


One way to remember an option and its use is to connect the option with its original word. Let's take a look at examples in a fun quiz format!




Q: Display a number of rows that matches with the word

A: -c (count)

↑Select the above row to see the answer

It counts the number of rows.



Q: Display the rows that contain the word with no case sensitive


A: -i (ignore case)

↑Select the above row to see the answer

It ignores cases and displays the word in all cases.



Q: Display the rows that do not contain the word


A: -v (invert match)

↑Select the above row to see the answer

It inverted matches. This one is perhaps a bit tricky since the option is not from the first letter of the word.



Q: Restrict the number of rows that contain the word


A: -m (max count)

↑Select the above row to see the answer

It restricts the maximum number of rows to display.



Q: Display only the word in the rows that contain the word


A: -o (only matching)

↑Select the above row to see the answer

It displays only the part of the row that matches the word.



How was the quiz? I personally found that it is easy to remember an option with the actual word that means the action of the option. Although there are a lot of options that do not match the results of action that letter meant, yet you can still remember them in this fun way.





bottom of page