在 Bash 中,文件以“-”开头

Dea*_*n J 4 bash

一个应用程序在我的 /tmp 目录中创建了一个名为“-123456”的目录。

在 Bash 中,rm -rf * 返回:bash: cd: -7: invalid option

rm -rf "-123456" 同样的事情。

帮助?

Bil*_*iss 10

使用“--”结束参数列表。因此:rm -rf -- -123456


Bry*_*yan 7

你试过rm -rf ./-123456吗?

编辑:为我工作

# ls -l
total 1
drwxr-xr-x 2 root root 4096 Mar 29 20:48 -test
# rm -rf ./-test
# ls -l
total 0
Run Code Online (Sandbox Code Playgroud)