command | xargs -I {} test.sh -p {} #编写一个脚本test.sh,-p是脚本的一个选项,command命令生成的输出传递给xargs,然后通过xargs将其转变成test.sh脚本的参数.
[cactier@localhost ~]$ find -name "*.sh" -print0 ./prostatus.sh./name.sh./test.sh[cactier@localhost ~]$ find -name "*.sh" -print ./prostatus.sh ./name.sh ./test.sh
xargs通常用于将文件名列表作为命令行参数传递给其他命令,故当文件名作为命令行参数的时候,建议用null作为文件名终结符号,而不是用空格
原文:http://www.cnblogs.com/aaa103439/p/3512833.html