command for grep the exact word
I have two lines in a file like below
Host * Host-specific * Here I want to grep the "Host *" line only. I had tried following way but I did not get exact line grep -w Host filename Please give the suggestions for grep exact line using specific word. Thanks, Nagendra. |
You already have it - it is simply that you have the wrong understanding of what a "word" is.
Have a look at the manpage again. Simplest for what you want might be to use character classes - [[:space:]] say - before and after the "word" you want. May lead to other surprises of course ... |
a simple soln:
Code:
grep 'Host ' filename |
If there is tab space between Host and * then we did not get output using
grep 'Host ' filename. Thanks, Nagendra |
yesterday's thread: http://www.linuxquestions.org/questi...-linux-721931/
mayby that will help you something. |
Quote:
Code:
grep Host[[:space:]] filename |
How about
cat <file> | grep "\Host\ " |
You may also want to try 'grep -x'
Code:
-x, --line-regexp |
All times are GMT -5. The time now is 12:04 AM. |