linux删除?字符目录,linux删除带有特殊字符的目录

刚才在测试脚本的时候创建了一个“--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哈哈~,成功,也干掉了。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值