本文介绍了XARGS长参数和命令之间的暂停的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果命令参数太长,Xargs将自动执行命令一次以上.

Xargs will execute command more than once automatically if the command arguments are too long.

我目前正在检索git中的修订差异,并将这些参数通过xargs传递给git归档.发生版本差异的时间很长,因此xargs会自动将命令拆分为两次.

I am currently retrieving the revision differences in git and passing those arguments to git archive through xargs. It happens that the revision differences are long hence xargs automatically split the command into two times.

因此,对于同一归档文件,git归档执行了两次,从而导致第二条命令清除了第一个命令所归档的内容.

Because of that, git archive done twice for the same archive that leads to whatever being archived by the first command is wiped out by the second command.

是否有任何方法可以让xargs在命令之间暂停或通知xargs存档到两个不同的zip文件中?

Is there any way to let xargs pause between command or maybe notify xargs to archive into two different zip file?

推荐答案

您可以让xargs运行任何您喜欢的命令;肯定是可以暂停或运行您在两次调用之间定义的另一个触发器的命令.

You can have xargs run any command you like; that certainly can be a command that pauses or runs another trigger you define between invocations.

因此,如果您当前正在运行:

So, if you're currently running:

xargs -0 doSomethingWithFiles

...您可以将其替换为:

...you can replace it with:

xargs -0 bash -c '"$@"; sleep 5' _ doSomethingWithFiles

这篇关于XARGS长参数和命令之间的暂停的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-14 18:25