Searching for a pattern in files using grep
is case-sensitive by default. Case sensitive means that grep looks for an exact match of your pattern in the related file. This may not surface all matches of the search value because of different writing styles for a given text.
This tutorial shows you how to search a pattern case insensitive in a file to see all matches, regardless the pattern’s writing style.
Ubuntu/Debian Series Overview
- Fix “sudo command not found”
- Install a Specific Version with apt-get on Ubuntu/Debian
- Fix Ubuntu/Debian apt-get “KEYEXPIRED: The following signatures were invalid”
- How to Test a Cron Job
- How to Unzip Into a Folder
- How to Show Your Elasticsearch Version on Ubuntu/Debian
- Use “which” in Linux to find the Location of an Exetable
- Sort “ls” by Last Changed Date
- How to Shutdown a Machine
- Show Hidden Files and Folders with `ls`
- Case Insensitive Search
Case-Insensitive Search with grep
grep has a --ignore-case
 flag to ignore the casing when searching for a pattern in a file. This flag tells grep to treat all letters in the pattern and the text in the source file the same, no matter the casing.
You can use the --ignore-case
flag or its shorthand -i
for case insensitive searching:
grep --ignore-case "pattern" storage/logs/app.log
# use the "-i" shorthand for "--ignore-case"
grep -i "pattern" storage/logs/app.log
That’s it!