grep
is very useful too to match and find phrases, words and characters in test. One of the most used situation is using grep
case sensitive or case insensitive. In this tutorial we will examine different examples. We have all ready examined grep
in the following tutorial.
Linux grep Command Tutorial with Examples
Case Sensitive
We will start with the default behavior of the grep
command which is case sensitive. In this example we will search for ismail
in /etc/passwd
.
$ grep "ismail" /etc/passwd

Case Insensitive
Now we will search for ISMAIL
in a case insensitive manner. We expect to match both ismail
and ISMAIL
in /etc/passwd
file. We will use -i
option in order to specify case insensitivity.
$ grep -i "ISMAIL" /etc/passwd

Case Insensitive and Recursive
In some cases we may need to search case insensitive and recursive manner. We will use -r
option in order to make our case insensitive searchs recursively. In this case we will search for ISMAIL
case insensitive in /etc
directory.
$ grep -r -i "ISMAIL" /etc
