Thursday, July 3, 2008

complicated rearrangements of text in UNIX

This shows how to take whitespace-delimited input and build something fancy from it:


echo -e "123 abc\n987 zyx" | awk '{ print "<nodeXXX attr1=\"" $1 "\">\n\t" $2 "\n\t<nodeYYY attr2=" $1 "/>\n</nodeXXX>"}'

No comments: