Say, I have a file like this :
cat >myfile
my name is sriram working in x company
my name is ramu working in y company
my name is psr working in z company
my name is rajesh working in global company
my name is ravi working in dash company
I want to pick all the names of the lines following the word "is" :
This is one way to do using sed out of millions of ways:
$mystr="is"; sed "s/.*$mystr \([^ ]*\) .*/\1/" myfile -- prints the following :
sriram
ramu
psr
rajesh
ravi
No comments:
Post a Comment