Egrep: difference between the option -w and \b

Is there difference between:

egrep -w "word" filename
egrep "\bword\b" filename

or both are equal?

Yes, they are same. For example, ‘\bFOO\b’ matches the separate word ‘FOO’:

grep -w 'FOO' input.txt
grep '\bFOO\b' input.txt
1 Like