linux - 为什么命令行 rm 不接受带有空格的目录的引号?
问题描述
由于空格和括号,在 Debian 命令行中运行rm projects/artwork/My Project (543893)/Images/*.png
不起作用。我需要逃离他们。但我认为引号 "" 是转义的替代方法。它适用于其他命令,例如cd
,但不适用于rm
. 这是为什么?
解决方案
因为 globbing 不适用于引用:
$ ll /tmp/"d i r"/*.png
-rw-r--r--. 1 postgres postgres 0 May 26 14:02 /tmp/d i r/a.png
-rw-r--r--. 1 postgres postgres 0 May 26 14:02 /tmp/d i r/p.png
$ ll "/tmp/d i r/*.png"
ls: cannot access /tmp/d i r/*.png: No such file or directory
$ rm "/tmp/d i r/*.png"
rm: cannot remove ‘/tmp/d i r/*.png’: No such file or directory
$ rm /tmp/"d i r"/*.png
$ ll /tmp/"d i r"/*.png
ls: cannot access /tmp/d i r/*.png: No such file or directory
推荐阅读
- database - Strapi 作为数据库
- java - Android Studio 中的 OnSlideRight() 函数
- flutter - 断言失败:第 551 行 pos 12:'child.hasSize':不正确
- flutter - 当列表项之一在颤动中刷新时,Listview 不会更新
- django - 我无法获取大文件并发布消息,当我在服务器中部署 django 和 vue 时
- android - 在 Android API 29 中访问外部存储
- android-studio - 类“QueryDocumentSnapshot”没有实例方法“[]”
- javascript - Javascript过滤器函数在生产中返回不同的结果
- android - Android - DialogFragment 不显示进入动画
- c# - 错误:ToastNotification 类型在 Windows.Foundation.UniversalApiContract 和 Windows.UI 中都存在