Reputation: 7487
Hello I actually am looking for a string which is a substring of another string. So I am using grep to get the matches of this string, but the matches of the other string too are coming up.
grep -nr 'XML' .
when I do this, the matches for string "LIBXMLX" are also coming up. Is there a way to get matches only of XML and no LIBXMLX??
I am newbie to shell scripting, so how do I proceed with this?
Upvotes: 0
Views: 604
Reputation: 246799
From the manual
The symbols \< and \> respectively match the empty string at the beginning and end of a word.
So,
grep -nr '\<XML\>' .
Upvotes: 3
Reputation: 424
It's kludgey, I know, but you could use ' XML' as the search string, thereby eliminating anything that doesn't have a space before the X. Just a thought. My interactions with grep are simple.
Upvotes: 0