How to grep for case insensitive string in a file?

BashShellAwkSedGrep

Bash Problem Overview


I have a file file1 which ends with Success... OR success...

I want to grep for the word success in a way which is not case sensitive way.

I have written the following command but it is case sensitive

cat file1 | grep "success\.\.\."

How can i change it so that it returns 0 with both Success... OR success...

Bash Solutions


Solution 1 - Bash

You can use the -i flag which makes your pattern case insensitive:

grep -iF "success..." file1

Also, there is no need for cat. grep takes a file with the syntax grep <pattern> <file>. I also used the -F flag to search for a fixed string to avoid escaping the ellipsis.

Solution 2 - Bash

For me SQL=echo $line | grep -iF "SQL"; IT works perfect

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionall_techieView Question on Stackoverflow
Solution 1 - BashImranView Answer on Stackoverflow
Solution 2 - BashDaljit SinzView Answer on Stackoverflow