企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
## 使用Linux命令删除一个目录下的所有文件,但保留一个指定文件 ~~~ [root@localhost test]# touch {1..10} [root@localhost test]# ls 1 10 2 3 4 5 6 7 8 9 [root@localhost test]# find -type f ! -name '5' |xargs rm -f # 删除全部但不包括5 [root@localhost test]# ls -l 总计 0 -rw-r--r-- 1 root root 0 09-15 15:42 5 ~~~ ~~~ [root@localhost test]# touch {1..10} [root@localhost test]# ls 1 10 2 3 4 5 6 7 8 9 [root@localhost test]# find -type f ! -name '5' -exec rm -f {} \; # 删除全部但不包括5 [root@localhost test]# ls 5 ~~~