Print only next pattern in a line after a pattern match

I have

2013-06-11 23:55:14 [17780] 1Umexd-0004cm-IG <= user@domain.com

I need sed/awk operation on this, so that it should print the very next pattern only after the the pattern mach <=

ie only print user@domain.com

awk 'BEGIN{FS="<= ";}{print $2}'
1 Like

Different way to enter field separator

awk -F"<= " '{print $2}'
awk '{print $2}' FS="<= "

another way
awk '{split($0,a,"<= ");print a[2]}'

1 Like

Thanks,

Its printing patterns after user@domain.com. I just need the next coloumn to <=

]# echo "2013-06-11 23:55:14 [17780] 1Umexd-0004cm-IG <= user@domain.com  XXX YY ZZZ" |awk 'BEGIN{FS="<= ";}{print $2}'
user@domain.com  XXX YY ZZZ
echo "2013-06-11 23:55:14 [17780] 1Umexd-0004cm-IG <= user@domain.com  XXX YY ZZZ" | awk -F"<= " '{split($2,a," ");print a[1]}'
user@domain.com
1 Like
 echo '2013-06-11 23:55:14 [17780] 1Umexd-0004cm-IG <= user@domain.com' | perl -nle 'print $2 if /(.*)\<\=\s*(\S+)\s*/;'

Thanks Jotne. Its working fine :slight_smile:

Another way to do it:
awk 'NR==2 {print $1}' RS="<="