func (){ local dir="$1" #local局部变量标识符 for f in `ls $1` do if [ -f "$dir/$f" ] then # echo "$dir/$f is file." if test -x $dir/$f && [ ${f##*.} != "sh" ] # 判断文件是否为 可执行文件, 且过滤掉 shell 脚本. then echo "$dir/$f is exe file." rm ...
1 问题 删除当前文件夹不包含文件1和文件2的其他所有文件,这个当前文件夹里面可以包含子文件夹,然后子文件夹里面也有文件1和文件2,但是这里的文件1和文件2也不应该被删除。 2 解决办法 可以用如下shell命令都行 find . -type f -not -name "1.txt" -not -name "2.txt" -exec rm -rf {} \; 1. fi...