Why in the following (e)grep
attempts, egrep
is unable to identify the end-of-word delimiter? (b
)?
$ echo -n "my-pc is beautiful" | egrep 'my-pc\b'
my-pc is beautiful
/home/pkaramol
$ echo -n "my-pc-vol2 is beautiful" | egrep 'my-pc\b'
my-pc-vol2 is beautiful
Same are the results with plain grep
?
Best Answer
It identifies it fine but
grep
andegrep
print the entire line of a match unless the-o
option is used:I think you want:
A word boundary is any non-word character. The word characters are:
[a-zA-Z0-9_]
. Therefore-
is not a word character.