Sometimes, we need to run a script to modify saveral files at once.
We can use xargs on shell tube.
ls | xargs echo
As the command before, xargs run echo and use the result from ls.
this example shows how to use xargs modify all index.html that change *.js
to *.js?ver=xxx
verStr="1.0.0"
# set version for .css .js files
find -name "index.html" | xargs -i cp {} {}.bak
find -name "index.html" | xargs sed -i 's@\.js.*\"@.js?ver='${verStr}'\"@g'
# reset files
# find -name "index.html" | xargs -i mv {}.bak {}
最近回复