问题描述
我已经不小心在GitBash(一个类似Unix的环境)中创建了一个文件,名称为 - -l (我完全不知道我如何设法在第一名:)
Johnny(master#)scipy-tentative-numpy-tutorials $ ls -l
total 1
-rw-r - r-- 1 Johnny administr 956 5月7日16:24 - -l
-rw-r - r-- 1 Johnny Administ 562 5月7日16:21 README.md
我希望删除(删除) - -l 文件。
我尝试了几种方法,但没有运气。例如
rm - -l
rm-\ \-l
rm -\ \-l
这些没有起作用。
请如何删除 - -l 文件?
谢谢! / p>
使用双连字符( -
)停止标志解析:
rm - -\ -l
或者,甚至可以使用选项卡完成:
rm - \- #然后在输入最后的$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $
$ b $ p
$ p
I have accidentally created a file in GitBash (a Unix like environment) with the name - -l
(I have absolutely no idea how I managed to do this in the first place :)
Johnny (master #) scipy-tentative-numpy-tutorials $ ls -l
total 1
-rw-r--r-- 1 Johnny Administ 956 May 7 16:24 - -l
-rw-r--r-- 1 Johnny Administ 562 May 7 16:21 README.md
I wish to delete (remove) that - -l
file.
I have tried a few ways but no luck. e.g.
rm "- -l"
rm "-\ \-l"
rm -\ \-l
These didn't work.
Please how do I delete the - -l
file?
Thank you!
解决方案 Use a double hyphen (--
) to stop flag parsing:
rm -- -\ -l
Alternatively, you can even use tab completion:
rm -- \- # Then press TAB immediately after typing the final -
This assumes that's the only file with a leading hyphen in the directory. Bash is smart enough to automatically escape the space in the middle of the file name.
这篇关于如何删除以破折号开头的文件(在Unix like模式下)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!