红联Linux门户
Linux帮助

删除“-”开头的文件

发布时间:2007-09-01 00:15:06来源:红联作者:beasept
对于文件名中含-的文件,rm命令容易认为这是命令选项,用rm *报:

rm: ERROR: Illegal option -- c
usage: rm [-fiRr] file...

删除的方法:
1 rm ./-filename 这样使-不是第一个字符。
2.rm -- -filename 用--告诉rm这是最后一个选项,参见getopt。有的系统用
rm - -filename
3.ls -i 列出inum ;用find . -inum inum_of_thisfile -exec rm '{}' \;
用这种方法可以删除含特殊字符的文件。

删除的方法:
1 rm -f ./-filename 这样使-不是第一个字符。
2.rm -f -- -filename 用--告诉rm这是最后一个选项,参见getopt。有的系统用
rm - -filename
3.ls -i 列出inum ;用find . -inum inum_of_thisfile -exec rm '{}' \;
用这种方法可以删除含特殊字符的文件。
文章评论

共有 0 条评论