当前时区为 UTC + 8 小时



发表新帖 回复这个主题  [ 2 篇帖子 ] 
作者 内容
1 楼 
 文章标题 : 关于xargs的小BUG
帖子发表于 : 2015-04-10 10:57 

注册: 2013-08-29 9:27
帖子: 41
送出感谢: 0 次
接收感谢: 0 次
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>
这回好了,为什么是这样呢?好像只有在带空格的中文文件夹中才会有此问题。


页首
 用户资料  
 
2 楼 
 文章标题 : Re: 关于xargs的小BUG
帖子发表于 : 2015-04-10 14:55 
头像

注册: 2008-09-18 13:11
帖子: 2781
送出感谢: 1
接收感谢: 453
你不去读一下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.


页首
 用户资料  
 
显示帖子 :  排序  
发表新帖 回复这个主题  [ 2 篇帖子 ] 

当前时区为 UTC + 8 小时


在线用户

正在浏览此版面的用户:没有注册用户 和 1 位游客


不能 在这个版面发表主题
不能 在这个版面回复主题
不能 在这个版面编辑帖子
不能 在这个版面删除帖子
不能 在这个版面提交附件

前往 :  
本站点为公益性站点,用于推广开源自由软件,由 DiaHosting VPSBudgetVM VPS 提供服务。
我们认为:软件应可免费取得,软件工具在各种语言环境下皆可使用,且不会有任何功能上的差异;
人们应有定制和修改软件的自由,且方式不受限制,只要他们自认为合适。

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
简体中文语系由 王笑宇 翻译