linux下删除带'-'的文件

581 查看

不知为何主目录下突然多了个-sV文件,目测是因为nmap的-sV参数产生的。
写下来权当做个笔记~

现在来模拟下当时的情况

touch -- -sV
touch ./-sV # 两种都行

现在工作目录底下会产生一个文件名为-sV的文件
如果执行

rm -sV

会产生一个错误

rm: invalid option -- 's'
Try 'rm --help' for more information.

原因是无效的参数s

本来打算Google下看看的,结果rm --help就看到答案了

To remove a file whose name starts with a '-', for example '-foo',
use one of these commands:
  rm -- -foo

  rm ./-foo