myfile.txt contains the following:
hello (ab)
hello ab
hello abcd
I've tried the following command:
$grep '\<ab\>' myfile.txt
\<
means a beginning of a word and \>
means end of word.
So I thought my grep command is equivalent to $grep ' ab ' myfile.txt
.I expected my output to be
hello ab
But it matches:
hello (ab)
hello ab
How is a word defined? Is it a string with a space in front of it and one more space following the string?
grep ' \<ab\>' myfile.txt