码迷,mamicode.com
首页 > 其他好文 > 详细

rm删除指定文件外其它文件

时间:2019-07-10 21:38:07      阅读:124      评论:0      收藏:0      [点我收藏+]

标签:rgs   centos   删除   rm -rf   gre   grep -v   其它   grep   指定   

[cqs@centos7 test000123]$ touch a.txt b.txt c.txt
[cqs@centos7 test000123]$ ls
a.txt b.txt c.txt

方法一:使用!取反
[[cqs@centos7 test000123]$ rm -rf !(a.txt)
[cqs@centos7 test000123]$ ls
a.txt

方法二:使用管道 grep -v取反
[cqs@centos7 test000123]$ ls ./|grep -v a.txt |xargs rm -rf
[cqs@centos7 test000123]$ ls
a.txt

rm删除指定文件外其它文件

标签:rgs   centos   删除   rm -rf   gre   grep -v   其它   grep   指定   

原文地址:https://blog.51cto.com/1929297/2419121

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!