免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2140 | 回复: 6
打印 上一主题 下一主题

rm的问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-04-16 10:47 |只看该作者 |倒序浏览
比如有不同后缀的文件,现在我想把后缀为sct的文件保留下来
其他的都删除

rm命令可以做到吗?
需要加哪个参数?

论坛徽章:
0
2 [报告]
发表于 2008-04-16 10:57 |只看该作者
哪你先把要的文件挪到别处, 删除之后再移回来不是更省事

论坛徽章:
0
3 [报告]
发表于 2008-04-16 11:02 |只看该作者
如果你用的是bash
可以打开glob扩展 shopt -s extglob
然后 rm -rf !(*.sct)

论坛徽章:
0
4 [报告]
发表于 2008-04-16 15:53 |只看该作者
find /path ! -name "*.sct"|xargs -n1 rm

论坛徽章:
0
5 [报告]
发表于 2008-04-16 16:07 |只看该作者
原帖由 davistar 于 2008-4-16 11:02 发表
如果你用的是bash
可以打开glob扩展 shopt -s extglob
然后 rm -rf !(*.sct)

nb
extglop都有啥特性?

论坛徽章:
0
6 [报告]
发表于 2008-04-16 16:12 |只看该作者
我猜就有点拓展regrex的意思 呵呵

论坛徽章:
0
7 [报告]
发表于 2008-04-16 16:27 |只看该作者
If  the  extglob  shell option is enabled using the shopt builtin, several extended
       pattern matching operators are recognized.  In the following  description,  a  pat-
       tern-list  is  a list of one or more patterns separated by a |.  Composite patterns
       may be formed using one or more of the following sub-patterns:

              ?(pattern-list)
                     Matches zero or one occurrence of the given patterns
              *(pattern-list)
                     Matches zero or more occurrences of the given patterns
              +(pattern-list)
                     Matches one or more occurrences of the given patterns
              @(pattern-list)
                     Matches one of the given patterns
              !(pattern-list)
                     Matches anything except one of the given patterns
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP