Ok, I've mostly solved this myself with a bunch of overhead and definitely not very much finesse. smile But so far I'm getting the datapoints I need and in a format I can use to extract the final bit I want. I had to continue to use other facilities from the bash script, including awk and some hard-coded echos since I was unable to figure out how to use only xmlstarlet.

Only one issue left...

Code:
SELECTMOVIE=`echo $TRAILERS | awk  'BEGIN { FS = "--DIVIDER--" } ; { print $7 }'`


How do I substitute that "$7" in the print statement with a variable?

EDIT: Solved.

Code:
movieNum=7
SELECTMOVIE=`echo $TRAILERS | awk -v record=$movieNum 'BEGIN { FS = "--DIVIDER--" } ; { print $record }'`


The -v argument allows you to pick up external variables and assign them to variables within awk.


I suppose since I'm here I might also pose another question which could be useful to me.

xmlstarlet has a formatting option which takes in a file, cleans it up and spits it out to stdout like so:

Code:
$ xml format infile.xml


You can obviously redirect that to a file if you'd like. I'm looking for a way to supply it with XML from a variable in bash without having to first save out the contents of the var to a file.

What I need is to have a single file in the end that has been properly formatted. I suppose I can save out a temporary file, format it out to the final file and then delete the temporary one. I was just hoping there was some way I could save that step or at least something less manual.


Edited by hybrid8 (14/01/2009 19:58)
_________________________
Bruno
Twisted Melon : Fine Mac OS Software