linux 删除特殊文件名的文件

  • 2019 年 10 月 4 日
  • 筆記

最近不小心touch文件时候,在文件名前面加了个短杠-,导致文件名类似于 -test.log 。 这样的话,按照常规的执行 rm -f '-test.log' 删除文件的时候,就会报错。类似如下: rm: invalid option — 't' Try 'rm ./-test.log' to remove the file ‘-test.log’.> Try 'rm –help' for more information. google了下,发现是因为linux将 横杠‘-’ 当成了命令选项了,我们只要执行 rm — '-test.log' 即可正常删除该文件。