Running a Case Insensitive Search Query with Grep
This guide extends the lesson on searching through files with grep and shows how to add the option for searching with a case insensitive option.
Guide Tasks
  • Read Tutorial
  • Watch Guide Video
Video locked
This video is viewable to users with a Bottega Bootcamp license

In the last guide, we talked about how we could implement universal search by leveraging the grep command in the Unix terminal. But now what happens if I were to do something like this, where I'm searching for Nav, but Nav has a capital letter?

If I quit out of this and run grep, and then search for nav, asterisk asterisk, slash asterisk dot erb, you can see that this doesn't actually pull up the file.

large

So that is a little bit of an issue because that's gonna lead to some kinda confusing results. So the way to fix this is, grep actually takes an optional flag of dash i, so if run dash i right here, hit return, you can see that now that pulls it up.

large

What dash i stands for is case insensitive search, or insensitive search, which means that nav is gonna work for capitals, lowercase, it's gonna completely ignore the type of case that it's in and it's simply gonna return anything that matches the nav regular expression.