【问题标题】:remove with double-asterisk wildcards does not work [duplicate]使用双星号通配符删除不起作用[重复]
【发布时间】:2017-03-08 10:16:11
【问题描述】:

我在test目录下有以下文件

.
./test2
./test2/test_doc1.txt
./test2/test1
./test2/test1/test_doc2.txt

当我使用rm -rf test/**/test_doc2.txt 时,它不会删除文件。 怎么了?

【问题讨论】:

  • 这个命令的输出是什么?
  • @xuhdev,沉默。没有消息。文件仍然存在。

标签: shell wildcard


【解决方案1】:

假设您正在使用 Bash。

shopt -s globstar
rm -rf test/**/test_doc2.txt

如果您总是想启用此功能,请将shopt -s globstar 添加到您的~/.bashrc 文件中。

【讨论】:

  • 如果您使用的是 OSX,请以同样的方式使用 shopt -s extglob
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2018-11-19
  • 2018-11-01
  • 2014-12-15
  • 2017-07-09
  • 1970-01-01
  • 2015-03-26
相关资源
最近更新 更多