From IT Mission Linux Tips, Hacks, Tutorials, Howtos - Itmission.org

Escaped-angle-brackets-mark-word-boundaries: Escaped-angle-brackets-mark-word-boundaries


Escaped angle brackets mark word boundaries.


The angle brackets must be escaped, since otherwise they have only their literal character meaning.

Escaped "angle brackets" -- \<...\> -- mark word boundaries.

The angle brackets must be escaped, since otherwise they have only their literal character meaning.

"\<the\>" matches the word "the," but not the words "them," "there," "other," etc.

bash$ cat textfile
This is line 1, of which there is only one instance.
 This is the only instance of line 2.
 This is line 3, another line.
 This is line 4.


bash$ grep 'the' textfile
This is line 1, of which there is only one instance.
 This is the only instance of line 2.
 This is line 3, another line.


bash$ grep '\<the\>' textfile
This is the only instance of line 2.

Reference : http://tldp.org


Retrieved from http://www.itmission.org/Escaped-angle-brackets-mark-word-boundaries/Escaped-angle-brackets-mark-word-boundaries
Page last modified on August 20, 2012, at 05:26 AM