I'm trying to write a script that will look through a directory, find all the XML files, run them through xmllint
, and save the formatted results to a file of the same name in a subdirectory called formatted
. Here's the script I have so far:
find . -maxdepth 1 -type f -iname "*.xml" | xargs -I '{}' xmllint --format '{}' > formatted/'{}'
This works, to an extent. The subdirectory ends up with one file, named "{}"
, which is just the results of the final file that was processed through xmllint
. How can I get the files to write properly to the subdirectory?
--output
option for xmllint. I tested both solutions (withxargs
and with-exec
) and they both work perfectly. Interestingly, thefind
man page mentions that "only one instance of'{}'
is allowed within the command" when you use-exec
, which is why I originally had opted forxargs
, but it worked just fine. – Junkman