问题
I'd like to recursively find every "foo.xml" file and on each foo.xml apply the xslt bar.xsl and save over the original foo.xml. When I run the following commands, separately, they work.
find . -name foo.xml
xsltproc -o foo.xml bar.xsl foo.xml
But, when I pipe them, nothing happens to foo.xml.
find . -name foo.xml | xargs xsltproc -o foo.xml bar.xsl
I think I'm missing something simple... Thanks, in advanced.
回答1:
Warning both of these will obviously overwrite the xml's with the transformation as asked in the question.
With xargs you want to do something like
find . -name foo.xml -print0 | xargs -I {} -0 xsltproc -o {} transform.xsl {}
Or with -exec
find . -name foo.xml -exec xsltproc -o {} transform.xsl {} \;
来源:https://stackoverflow.com/questions/22794421/batch-xslt-transformation-find-xarg-xsltproc