« Update Plugins for TC (Total Commander 6.03) |
Main
| SOPHOS.ANTIVIRUS.V3.80.MULTILANGUAGE.LINUX-FeDEX »
April 15, 2004
bash scripts sample - for loop v.s. xargs
版权声明:可以任意转载,转载时请务必以超链接形式标明文章原始出处和作者信息及本声明。
https://windtear.net/archives/2004/04/15/000305.html
-----> Demand: getpoints 1.jpg 1.points getpoints 2.jpg 2.points ...
% cat list.txt 1.jpg 2.jpg ...
-----> Solution: 1. for i in `cat list.txt`;do ./getpoints $i $i.points;done rename jpg.points points *.points
2.(by newclear) cat list.txt | sed -e "s/\..*//" | xargs --replace ./getpoints {}.jpg {}.points
-----> Demo % for i in `cat list.txt`;do echo $i $i.points;done 1.jpg 1.jpg.points 2.jpg 2.jpg.points 3.jpg 3.jpg.points
rename jpg.points points *.points
% cat list.txt | sed -e "s/\..*//" | xargs --replace echo {}.jpg {}.points 1.jpg 1.points 2.jpg 2.points 3.jpg 3.points
|
|
Posted by windtear at April 15, 2004 6:17 PM