1.先找出要修改的文件名保存在一个1.txt中;
2.创建一个修改后的文件名文件 sed 's/@/_/g' 1.txt >2.txt ;
3. 把要运行的重命名命令写到一个文件中
paste 1.txt 2.txt >3.txt
4.批量处理
cat 3.txt |while read line;do rename $line ;done
直接用 rename 命令即可。不过跟楼上的不同。
百度不让发,没办法写到附件里上传。
#!/bin/bash
for file in `find /test -type f`;do
newfile=`echo $file|sed 's/@/_/g'`;
/bin/mv $file $newfile;
done
直接用rename就好
rename 's/@/_' *.txt