LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   grep exact letters (https://www.linuxquestions.org/questions/linux-newbie-8/grep-exact-letters-603633/)

packets 11-30-2007 08:05 PM

grep exact letters
 
I used grep everyday. However, is there a parametes to grep an exact word. Let's say there is a word nelso, nels, nelson. If I grep "nels", it will show the three. Can I do a grep where it wil only display "nels" and not including nelson and nelso?

Tinkster 11-30-2007 08:39 PM

Use the word-boundry metacharacter.

Code:

]$ cat huh
nelson
nelso
nels

Code:

grep '\bnels\b' huh
nels


Cheers,
Tink


All times are GMT -5. The time now is 09:41 PM.