首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何使用通配符删除文件?

如何使用通配符删除文件?
EN

Stack Overflow用户
提问于 2022-11-16 12:48:03
回答 1查看 35关注 0票数 -1

带有通配符的rm不起作用。

如果有以ef1 & ef2命名的文件,那么我尝试删除ef1 & ef2。

$ rm ef*这不能擦除ef1 & ef2。

但是就像下面一样,单文件rm正在工作。$ rm ef1 $ rm ef2

尝试用*创建要删除的文件(星号、通配符)

asdf@asdf:~/Documents/rust/hello$ touch ef1 ef2

asdf@asdf:~/Documents/rust/hello$ ls

ef1 ef2 hello main.rs test.c test_c

asdf@asdf:~/Documents/rust/hello$ rm ef*

rm:无法删除“ef*”:没有这样的文件或目录

为什么我不能删除ef1和ef2?

asdf@asdf:~/Documents/rust/hello$ rm -r ef*

rm:无法删除“ef*”:没有这样的文件或目录

asdf@asdf:~/Documents/rust/hello$ rm -f ef*

asdf@asdf:~/Documents/rust/hello$ rm -rf ef*

asdf@asdf:~/Documents/rust/hello$ sudo rm ef*

rm:无法删除“ef*”:没有这样的文件或目录

asdf@asdf:~/Documents/rust/hello$ ls

ef1 ef2 hello main.rs test.c test_c

为什么我不能删除ef1和ef2?

别名rm

bash:别名: rm:找不到

型rm

rm被散列(/usr/bin/rm)

,rm,

/usr/bin/rm

\rm ef*

rm:无法删除“ef*”:没有这样的文件或目录

echo $-

himBHs

EN

回答 1

Stack Overflow用户

发布于 2022-11-19 15:36:07

浪费了两天时间..。

我终于找到了自己的答案。不幸的是,问题在于我自己。

我专注于使用通配符与"sudo -i“一起工作的rm。所以我检查了.bashrc并找到了单行的解决方案。一旦我评论掉了源~~,那么问题就解决了。

在上述来源处有低谷线。我不知道我为什么那样做。

#!/bin/sh #GLOBIGNORE="*“

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/74460710

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档