Skip to main content
replaced http://unix.stackexchange.com/ with https://unix.stackexchange.com/
Source Link

Thanks to RobertLRobertL for this answeranswer.

I also came up with a combination of grep/awk/sed to achieve the same but it is slower obviously. Just wanted to put it out there.

egrep -w ""\<SOURCE"|"SOURCEFIELD.*XYZ.*"" sample.xml|grep -B1 XYZ|grep -w SOURCE|\                                                              
> awk -F" NAME =" '{print $2}'|awk '{print $1}'|sed 's/"//g'

Thanks to RobertL for this answer.

I also came up with a combination of grep/awk/sed to achieve the same but it is slower obviously. Just wanted to put it out there.

egrep -w ""\<SOURCE"|"SOURCEFIELD.*XYZ.*"" sample.xml|grep -B1 XYZ|grep -w SOURCE|\                                                              
> awk -F" NAME =" '{print $2}'|awk '{print $1}'|sed 's/"//g'

Thanks to RobertL for this answer.

I also came up with a combination of grep/awk/sed to achieve the same but it is slower obviously. Just wanted to put it out there.

egrep -w ""\<SOURCE"|"SOURCEFIELD.*XYZ.*"" sample.xml|grep -B1 XYZ|grep -w SOURCE|\                                                              
> awk -F" NAME =" '{print $2}'|awk '{print $1}'|sed 's/"//g'
Source Link
Utsav
  • 450
  • 2
  • 9

Thanks to RobertL for this answer.

I also came up with a combination of grep/awk/sed to achieve the same but it is slower obviously. Just wanted to put it out there.

egrep -w ""\<SOURCE"|"SOURCEFIELD.*XYZ.*"" sample.xml|grep -B1 XYZ|grep -w SOURCE|\                                                              
> awk -F" NAME =" '{print $2}'|awk '{print $1}'|sed 's/"//g'