Using Grep Case Insensitive


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 Sensitive
Case Sensitive

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
Case Insensitive

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
Case Insensitive and Recursive
Case Insensitive and Recursive

LEARN MORE  How To List Installed Packages In Ubuntu, Debian, Kali, Mint

Leave a Comment