如何删除名称以“-"开头的文件 [英] How to remove a file whose name starts with '-'

查看:151
本文介绍了如何删除名称以“-"开头的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在脚本中犯了一个错误之后,我得到了一个以短划线开头的文件,-:

After a mistake in a script I ended up with a file whose name starts with a dash, -:

-myfile.txt

我到目前为止已经尝试过:

I tried so far:

rm -myfile.txt
rm: illegal option -- m
usage: rm [-f | -i] [-dPRrvW] file ...
       unlink file

rm "-myfile.txt"
rm: illegal option -- m
usage: rm [-f | -i] [-dPRrvW] file ...
       unlink file

rm "\-myfile.txt"
rm: \-myfile.txt: No such file or directory

rm \-myfile.txt
rm: illegal option -- m
usage: rm [-f | -i] [-dPRrvW] file ...
       unlink file

rm "-"myfile.txt
rm: illegal option -- m
usage: rm [-f | -i] [-dPRrvW] file ...
       unlink file

如何删除此文件?

推荐答案

感谢@ ajp15243: 答案是:

Thanks to @ajp15243 : the answer is :

rm ./-myfile.txt

rm -- -myfile.txt

这篇关于如何删除名称以“-"开头的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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