我正在编写一个简单的程序来运行系统中各个目录中的一堆文件.基本上,它涉及打开它们并检查有效的XML.该程序的选项之一是列出错误的xml文件.
这使我想到了我的问题.最好的输出格式以用于XARGS.我以为将每个条目放在换行符上就足够了,但是似乎有些混乱.因为文件名都带有空格.
所以说我的输出是:
./dir name 1/file 1.xml
./dir name 2/file 2.xml
./dir name 3/file 3.xml
./myprogram.py --list BADXML | xargs -d '\n' cat
所以..我或者误解了如何使用XARGS,或者我需要稍微改变程序输出的格式.我不确定最好的最容易使用的路线.如果我可以避免的话,我将不得不总是输入一堆xarg选项.
解决方法:
男人xargs
–null
-0 Input items are terminated by a null character instead of by
whitespace, and the quotes and
backslash are not special (every
character is taken literally).
disables the end of file string, which
is treated like any other argument.
Useful when input items might contain
white space, quote marks, or
backslashes. The GNU find -print0
option produces input suitable for
this mode.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。