【问题标题】:How to remove matching files but exclude some如何删除匹配的文件但排除一些
【发布时间】:2016-02-29 08:44:03
【问题描述】:

我在当前目录中有以下文件:

./
-- 1
-- a2
-- abca
-- abcb
-- abcc
-- abcd
-- abce
-- abcf
-- abcg
-- abch
-- test01
-- test02
-- test03
-- test04
-- test05
-- test06
-- test07
-- test08
-- test09
-- test10

我想删除所有test* 文件,但排除test07test09。 如何做到这一点?

rm test* !test07 !test09 不起作用

【问题讨论】:

  • shopt -s extglob; rm test0+(1|2|3|4|5|6|8) test10 可能吗?
  • find . -maxdepth 1 -name test\* ! -name test07 ! -name test09 -exec rm {} + 也许?

标签: shell glob rm


【解决方案1】:

GLOBIGNORE="test0[79]"; rm test* 可能吗?

【讨论】:

    猜你喜欢
    • 2017-01-28
    • 2018-07-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-06-25
    • 2013-03-04
    • 1970-01-01
    相关资源
    最近更新 更多