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

Popular posts from this blog

node.js - Using Node without global install -

How to access a php class file from PHPFox framework into javascript code written in simple HTML file? -

java - Null response to php query in android, even though php works properly -