如何删除以破折号开头的文件(在Unix like模式下) [英] How to remove a file beginning with a dash (in Unix like mode)

查看:204
本文介绍了如何删除以破折号开头的文件(在Unix like模式下)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经不小心在GitBash(一个类似Unix的环境)中创建了一个文件,名称为 - -l <​​/ code>(我完全不知道我如何设法在第一名:)

  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 <​​/ code>文件。



我尝试了几种方法,但没有运气。例如

  rm -  -l
rm-\ \-l
rm -\ \-l

这些没有起作用。



请如何删除 - -l <​​/ code>文件?



谢谢! / p>

解决方案

使用双连字符( - )停止标志解析:

  rm  -  -\ -l 

或者,甚至可以使用选项卡完成:

  rm  -  \- #然后在输入最后的$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ 
$ b $ p

$ p <目录。 Bash足够聪明,可以自动转义文件名中间的空格。


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模式下)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆