rm命令如何在删除文件时排除忽略某特定文件
[root@zc zc]# touch test{1..10}
[root@zc zc]# ls
test1  test10  test2  test3  test4  test5  test6  test7  test8  test9

方法一:find
[root@zc zc]# ls
test1  test10  test2  test3  test4  test5  test6  test7  test8  test9
[root@zc zc]# find /zc -type f ! -name "test10"|xargs rm -f 
[root@zc zc]# ls
test10
[root@zc zc]# find /zc -type f ! -name "test10" -exec rm -f {} \;     
[root@zc zc]# ls
test10
[root@zc zc]# find /zc -type f -not -name "test10" -exec rm -rf {} \;
[root@zc zc]# ls
test10
[root@zc zc]# find /zc -type f -not -name "test10" | xargs rm -rf
[root@zc zc]# ls
test10

方法二:rsync
[root@zc zc]# ls
test1  test10  test2  test3  test4  test5  test6  test7  test8  test9
[root@zc zc]# mkdir /null && rsync -az --delete --exclude "test10" /null/ /zc/
[root@zc zc]# ls
test10

方法三:开启bash的extglob功能(此功能的作用就是用rm !(*jpg)这样的方式来删除不包括号内文件的文件)
[root@zc zc]# shopt -s extglob
[root@zc zc]# ls
test1  test10  test2  test3  test4  test5  test6  test7  test8  test9
[root@zc zc]# rm -f !(test10)
[root@zc zc]# ls
test10

方法四:
[root@zc zc]# find ./ -type f|grep -v "test10"|xargs rm -f
[root@zc zc]# ls
test10

方法五:
[root@zc zc]# rm -f `ls|grep -v "test10"`
[root@zc zc]# ls
test10

方法六: shell
[root@zc zc] for i in `ls`;do if [ "$i" != test10 ];then rm -rf $i;fi;done;