The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM



View Single Post in UNIX Forums - Click on the Thread or Permalink to View Entire Thread -->
  #2 (permalink)  
Old 01-23-2008
fpmurphy fpmurphy is offline
Moderator
 

Join Date: Dec 2003
Location: /dev/fl
Posts: 1,122
One way is to use sed repeatedly as the following example shows.

Code:
 sed -n '/\<Family2\>/,/\<\/Family2\>/p' file | sed -n '/\<Father\>/,/\<\/Father\>/p' | sed -n 's/\<name=\(.*\)\/\>/\1/p'
It outputs "DAVE".

A better way is to use something like the XML extension to gawk (XMLgawk)
Reply With Quote