Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sed + how to get the second word (string) after "=" separator by sed

Tags:

sed

how to get the second word (string) after "=" separator by sed (need to ignore spaces)

for example

   echo " bla bla word word1 = strin1 string2 " | sed .....

I should get string2

another example

    echo " bla bla word word1 =swhsw 123  " | sed .....

I should get 123

like image 936
lidia Avatar asked Jul 22 '10 11:07

lidia


1 Answers

$ echo " bla bla word word1 = strin1 string2 " | sed 's/.[^=]*=\(.[^ \t]*\)[ \t]*\(.[^ \t]*\)\(.*\)/\2/'
string2


$ echo " bla bla word word1 =swhsw 123  " | awk -F"=" '{split($2,a," ");print a[2]}'
123

And how about you start reading up on how to use sed/awk ?

like image 138
ghostdog74 Avatar answered Oct 16 '22 16:10

ghostdog74