bash - Linux -> Terminal command -> Grep -> Expressions / Exceptions related to symbol -
simply: have problem command should print me lines containing of 2 expressions: "king" , "king's son". got far:
grep -w "king's son\|king" frog.txt it work include "king's" should not happen.
adding -v grep "king's" not work deletes "king's son" also.
i using ubuntu 32 bit system installed on virtual box machine.
this oughta it:
grep -e "(^|[ \t])(king|king's son)([ \t]|$)" frog.txt it uses groups (^|[ \t]) , ([ \t]|$) match word separators or beginning/end of lines.
Comments
Post a Comment