看看这个可以么?没在公司,不能测试for example from *.abc to *.cde
source=`ls *.abc`
for file in $source
do
newfile=`echo $file | sed s'/.abc/.cde/g'`
#先不要用mv, 用echo看看$newfile名字对不,
#免得给你文件弄坏了
mv $file $newfile
done
tested in Solaris 2.5 successfully.
Before test:
~/tmp/test/[116]> ls
~/tmp/test/[116]> 1 2 1.abc 2.abc 3.dd
After test:
~/tmp/test/[116]> ls
~/tmp/test/[116]> 1 2 1.cde 2.cde 3.dd
Please try.
~/tmp/test/[116]> ls
~/tmp/test/[116]> 1 2 1.abc 2.abc 3.dd
After test:
~/tmp/test/[116]> ls
~/tmp/test/[116]> 1 2 1.cde 2.cde 3.dd
Please try.