#!/bin/ksh ################################################################################ # Print a XML section # # Written by Matt Baker mbaker@computeranddata.com ################################################################################ DEBUG=0 usage () { print "Usage error" print "$0 [-debug] -p starting-search-pattern -f filename" print "" print "i.e. $0 -p zone -f /etc/zones/myzone.xml" print "" exit 1 } if (( ! $# )) then print "Usage: must provide an argument." exit 1 fi while (( $# )) do case "$1" in -debug) shift DEBUG=1 set -x ;; -p) shift PATTERN=$1 shift ;; -f) shift FILE=$1 shift if [[ ! -f $FILE ]] then print "ERROR:3:File $FILE not found" exit 3 fi ;; *) print "Usage: incorrect argument." usage ;; esac done cat $FILE | awk '/^<'$PATTERN'/,/^<\/'$PATTERN'>/ {print $0}'