rm在命令行上工作,但不在脚本中工作
当我rm *.old.*在命令行上执行时,它会正确删除,但是当我在脚本的以下部分中执行此操作时,它不会保留所有*.old.*文件。 我的bash脚本出了什么问题: for i in ./*; do if [[ -f $i ]]; then if [[ $i == *.old.* ]]; then oldfile=$i echo "this file is to be removed: $oldfile" rm $oldfile exec 2>errorfile if [ -s $errorfile ] then echo "rm failed" else echo "removed $oldfile!" fi else echo …