先看两个特殊文件(以-开头)
[root@node_119 test]# ll
total 0
-rw-r--r-- 1 root root 0 Aug 3 08:59 -rf *
-rw-r--r-- 1 root root 0 Aug 3 09:00 -test
上面两个文件用普通方法无法删除
[root@node_119 test]# rm '-rf *'
rm: invalid option -- ' '
Try 'rm ./'-rf *'' to remove the file ‘-rf *’.
Try 'rm --help' for more information.
[root@node_119 test]# rm -rf\ \*
rm: invalid option -- ' '
Try 'rm ./'-rf *'' to remove the file ‘-rf *’.
Try 'rm --help' for more information.
删除方法,在文件名前加--
[root@node_119 test]# rm -rf -- '-rf *'
[root@node_119 test]# rm -rf -- -test
[root@node_119 test]# ll
total 0
两个文件已被删除,点个赞
来自:Linux命令手册
往期推荐
开源~新款装机神器!启动 U盘 告别格式化,直接挂载多 ISO
黑客 Shell 神技:掩盖 Linux 服务器上的操作痕迹
超全面的 Kubernetes 容器网络技能,运维看后都说好
致运维:关于 Kubernetes 的架构,看完这篇你就明白了
关注「开源Linux」加星标,提升IT技能
有收获,点个在看