How to use variable in xargs
如何在xargs中使用变量{}
$ ls
1.txt 2.txt 3.txt log.xml
$ ls *.txt |xargs -t -i mv {} {}.bak
mv 1.txt 1.txt.bak
mv 2.txt 2.txt.bak
mv 3.txt 3.txt.bak
$ ls
1.txt.bak 2.txt.bak 3.txt.bak log.xml -I R same as --replace=R
-i, --replace[=R] replace R in INITIAL-ARGS with names read
from standard input; if R is unspecified,
assume {}find . | xargs -I {} cp {} $D_PATH
or
find . | xargs -i cp {} $D_PATH
find *.pl | xargs -t -n 1 -I {} cp {} {}_dayuan.pl
cp lab3a_1.pl _dayuan.pl
cp lab3a_2.pl _dayuan.pl
cp lab3a_3.pl _dayuan.pl
cp lab3b_1.pl _dayuan.pl
cp lab3b_2.pl _dayuan.pl
cp lab3b_3.pl _dayuan.pl
find *.pl | xargs -t -n 1 -I {} cp {} '{}'_dayuan.pl
cp lab3a_1.pl lab3a_1.pl_dayuan.pl
cp lab3a_2.pl lab3a_2.pl_dayuan.pl
cp lab3a_3.pl lab3a_3.pl_dayuan.pl
cp lab3b_1.pl lab3b_1.pl_dayuan.pl
cp lab3b_2.pl lab3b_2.pl_dayuan.pl
cp lab3b_3.pl lab3b_3.pl_dayuan.plPreviousZsh autosuggestion bindkeyNextUse Find to find all files ending with .sh and do one more thing
Last updated
Was this helpful?