suse@linux-337q:~/downs> find . -name '*.txt'
./d.txt
./新建 文件夹/m.txt
suse@linux-337q:~/downs> find . -name '*.txt' | xargs rm -rf
suse@linux-337q:~/downs> find . -name '*.txt'
./新建 文件夹/m.txt
为什么删不掉m.txt?有问题吧。
我换一种方法:
suse@linux-337q:~/downs> find . -name '*.txt' -exec rm -rf {} \;
suse@linux-337q:~/downs> find . -name '*.txt'
suse@linux-337q:~/downs>
这回好了,为什么是这样呢?好像只有在带空格的中文文件夹中才会有此问题。
关于xargs的小BUG
-
- 帖子: 41
- 注册时间: 2013-08-29 9:27
- astolia
- 论坛版主
- 帖子: 6703
- 注册时间: 2008-09-18 13:11
Re: 关于xargs的小BUG
你不去读一下xargs的manpage么?
Because Unix filenames can contain blanks and new‐
lines, this default behaviour is often problematic;
filenames containing blanks and/or newlines are in‐
correctly processed by xargs. In these situations it
is better to use the -0 option, which prevents such
problems. When using this option you will need to
ensure that the program which produces the input for
xargs also uses a null character as a separator. If
that program is GNU find for example, the -print0 op‐
tion does this for you.