刚才在测试脚本的时候创建了一个“--help”的目录,当是用rm
--help的时候删不掉,因为这个目录的一个字符是“-”linux把他当成一个参数来看了,删除不掉。
但是看到提示如下说:
By default, rm does not remove direct
更多来源:http://www.ok.xz.cn
ories. Use the --recursive (-r or -R)
option to remove each listed directory, too, along with all of its
contents.
To remove a file whose name starts with a `-', for example
`-foo',
use one of these commands:
rm -- -foo
rm ./-foo
Note that if you use rm to remove a file, it is usually possible to
recover
the contents of that file. If you want more assurance that the
contents are
truly unrecoverable, consider using shred.
用第一种方法试试:
[guo@localhost net-snmp-5.4.2.1]$ rm -- --help
rm: cannot remove `--help': Is a directory
用第二种方法试试:
[guo@localhost net-snmp-5.4.2.1]$ rm ./--help
rm: cannot remove `./--help': Is a directory
mygod都不行,怎么办呢?加上-fr试试:
[guo@localhost net-snmp-5.4.2.1]$ rm -fr -- --help
O(∩_∩)O哈哈~,成功,干掉了。
在建立一个特殊字符目录试试:
[guo@localhost net-snmp-5.4.2.1]$ ./mkinstalldirs --help
mkdir ./--help
[guo@localhost net-snmp-5.4.2.1]$ rm -fr ./--help
O(∩_∩)O哈哈~,成功,也干掉了。