How to grep exact word from file in linux 

Let Say I have file contain following data :

[root@amit ~]# cat word.txt
redhat
Redhat
redhat Redhat
redhat123
Redhat123
123Redhat
123redhat

Now I  want to grep word redhat by simple search.

[root@amit ~]# grep redhat word.txt
redhat
redhat1 Redhat
redhat123
123redhat

But It include words redhat1, redhat123 and 123redhat  as well

Now I want  to search "EXACT"  redhat word  from input file.  (we can use -w option grep) to achive this.

[root@amit ~]# grep -w redhat word.txt
redhat

Great :) 


 
Top
Maintained By Amit Maheshwari