InsecureNoob InsecureNoob - 4 months ago 27
Linux Question

How to xmlstarlet on multiple files and append the output?

I am using CSH Shell.

My Current Working xmlstarlet command (does an xmlstarlet operation on a single file and the result is pasted in an output text file):

xmlstarlet sel -t -m '//RESULT_STEP' -v '@time_stamp' -o '|' -v '@step_name' --nl Report1.xml > /scratch/rys/view_storage/out.txt

Now I need to this on multiple files Report1.xml and Report2.xml and store the appended result in an output file like above.

Is it possible to do this with xmlstarlet?

Answer

You'd use your shell to do it. Example for bash:

{
  for xmlfile in Report1.xml Report2.xml
  do
    xmlstarlet sel ... "$xmlfile"
  done
} > .../out.txt