Accorging to GNU documentation:\< Match the empty string at the beginning of word.\> Match the empty string at the end of word.My /etc/fstab looks like this:/dev/sdb1       /media/fresh      ext2   defaults     0 0I want grep to return TRUE/FALSE for the existence of /media/fresh. I tried to use \< and \> but it didn't work. Why?egrep '\</media/fresh\>' /etc/fstabWorkaround:egrep '[[:blank:]]/media/fresh[[:blank:]]' /etc/fstabBut it looks uglier.My grep is 2.5.1
Grep word boundaries
grep;regular expression
\< and \> match empty string at the begin and end of a word respectively and only word constituent characters are:[[:alnum:]_]From man grep:Word-constituent characters are letters, digits, and the underscore.So, your Regex is failing because / is not a valid word constituent character.Instead as you have spaces around, you can use -w option of grep to match a word:grep -wo '/media/fresh' /etc/fstabExample:$ grep -wo '/media/fresh' <<< '/dev/sdb1       /media/fresh      ext2   defaults     0 0'/media/fresh