grep is one of the most useful tools to find text characters, words and phrases inside your Linux box. Today we will show you how the correct usage of grep case sensitive parameter to find the exact information you need.
Let’s suppose you have two words inside a text file: Hello and hello.
If you run a normal grep, like:
grep hello nixcp.txt
The output will show you only the only find lines containing the line that contains “hello” word. As you see, grep is not case sensitive.
However, if you add the -i parameter, you this will make grep cases sensitive, let’s try again.
grep -i "Hello" nixcp.txt
Lot of new Linux and Unix users often use cat and then grep, it is not bad to use both commands, but it is not useful at all because you are adding more commands to something that doesn’t really need it. Example of case sensitive grep using cat:
cat nixcp.txt | grep -i “Hello”
Both examples will show you the complete list of matching words that begin with “hello” and “Hello”, it will even find words like HELLO or heLLo if you add that to the text file. It will make it really easier to find the desired characters when you need.
Check out this video where we show a practical usage of grep case sensitive option using -i parameter:
`grep -i` – it’s: “case INSENSITIVE”, e.g. it IGNORE CASE as you highlighted in man page…
Case sensitive command is just `grep` without options…