如何用shell实现sco unix系统多级目录下文件名的批量修改?

举个例子:
我要把 ./src/d1/A101.src
./src/d1/A102.src
./src/d2/A201.src

替换为 ./src/d1/B101.src
./src/d1/B102.src
./src/d2/B201.src

--------------------------------------------------------------

#!/bin/sh

func()
{
cd $1
for s in *
do
if [ -d $s ]; then
func $s
continue
fi
t=`echo $s ¦ sed "s/^A\(...\.src\)/B\1/g"
if [ $s != $t ]; then
mv $s $t
fi
done
cd ..
}

func .

Published At
Categories with 服务器类
Tagged with
comments powered by Disqus