在脚本中出现错误后,我最终得到了一个名称以破折号开头的文件,-
:
-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
使用绝对路径名
像rm/home/name/-myfile.txt
您可以随时尝试inode解决方案:
$ ls -al -i | grep me
2116530 -rw-rw-r-- 1 user123 user123 0 Feb 27 12:39 me
2116530
是文件的索引节点。然后你可以使用查找删除它
find ./ -inum 2116530 --delete
甚至
find ./ -inum 2116530 -exec rm {} ;
试试这个将您的文件名放在"-"中例如:rm "-myfile.txt"