bash – 如何删除名称以’ – ‘开头的文件[复制]

前端之家收集整理的这篇文章主要介绍了bash – 如何删除名称以’ – ‘开头的文件[复制]前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
参见英文答案 > How to remove files starting with double hyphen?7个
> rm cannot delete files starting with — 3个
在脚本出错后,我最终得到了一个名称以短划线’ – ‘开头的文件

-myfile.txt

我到目前为止尝试过:

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:
答案是 :
rm ./-myfile.txt

要么

rm -- -myfile.txt

猜你在找的Bash相关文章