The file named {}
that you see should probably contain all of the formatted files together. The reason for this is that the redirection that you are using is not actually a part of the command that xargs
sees. The redirection is interpreted by the shell, so what it does is run
find . -maxdepth 1 -type f -iname "*.xml" | xargs -I '{}' xmllint --format '{}'
and save the output to the file named formatted/{}
.
Try using the --output
option of xmllint
instead of the redirection:
... | xargs -I '{}' xmllint --format '{}' --output formatted/'{}'
You can also avoid calling xargs
by using the -exec
option of find
:
find . -maxdepth 1 -type f -iname "*.xml" -exec xmllint --format '{}' --output formatted/'{}' \;