#!/bin/sh ./xmlstarlet ed \ -s /xml/table/rec -t elem -n new-field -v new-value \ -i '$prev' -t attr -n new-attr -v new-attr-value \ xml/table.xml