How to grep ignore case in linux/unix

Grep ignore case search can help us quickly search for the content we need to query.

The grep -i option can perform case insensitive matching. We can use the grep -i option to ignore case.

grep syntax

➜  ~ grep -i "keyword" file
  • -i, –ignore-case
    Perform case insensitive matching. By default, grep is case sensitive.

grep examples

In the following grep example, we use the grep -i option to search for keywords in the file ignores case.

➜  ~ grep -i "use" test.log
grep ignore case

In the following grep example, we use the grep -i option and -R option to search for keywords in a directory without case-sensitivity.

  • -R, -r, –recursive
    Recursively search subdirectories listed.
➜  test grep -iR "use" .

Add a Comment

Your email address will not be published. Required fields are marked *