我想用另一个前缀(重命名)替换目录中所有文件的前缀。脚本不替换文件名的前缀
这是我的脚本
# Script to rename the files
#!/bin/bash
for file in $1*;
do
mv $file `echo $file | sed -e 's/^$1/$2/'`;
done
在与
rename.sh BIT SIT
执行脚本我收到以下错误
mv: `BITfile.h' and `BITFile.h' are the same file
mv: `BITDefs.cpp' and `BITDefs.cpp' are the same file
mv: `BITDefs.h' and `BITDefs.h' are the same file
好像sed
是治疗$1
和$2
一样价值,但是当我p在另一行上打印这些变量表明它们不同。
不要忘了接受低于他们是否帮助你:-) –