如何使用" xargs的"当正确的参数列表太长 [英] How to use "xargs" properly when argument list is too long

查看:163
本文介绍了如何使用" xargs的"当正确的参数列表太长的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以请给我上使用以下操作xargs的例子吗?

Can someone please give me an example of using xargs on the below operation?

tar c $dir/temp/*.parse\
    | lzma -9 > $dir/backup/$(date '+%Y-%m-%d')-archive.tar.lzma

我得到的bash错误 /斌/焦油:参数列表太长

Particularily我试图做4500个文件LZMA COM pression;所以这并不奇怪。我只是不知道如何修改上面使用的xargs,摆脱错误的!谢谢你。

Particularily I am trying to do LZMA compression on about 4,500 files; so this isn't surprising. I just don't know how to modify the above to use xargs and get rid of the error! Thanks.

推荐答案

拓展上CristopheDs答案,假设你使用bash:

Expanding on CristopheDs answer and assuming you're using bash:

tar c --files-from <(find $dir/temp -maxdepth 1 -name "*.parse") | lzma -9 > $dir/backup/$(date '+%Y-%m-%d')-archive.tar.lzma

究其原因的xargs 不帮助你在这里的是,直到所有的参数都被使用它会做多次调用。这不会帮助你在这里,因为这将创造的若干个的tar档案,你不想要的。

The reason xargs doesn't help you here is that it will do multiple invocations until all arguments have been used. This won't help you here since that will create several tar archives, which you don't want.

这篇关于如何使用&QUOT; xargs的&QUOT;当正确的参数列表太长的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆