XARGS Long Arguments and Pause Between Commands

半城伤御伤魂 提交于 2019-12-06 14:03:45

问题


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

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.

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.

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


回答1:


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


来源:https://stackoverflow.com/questions/53688284/xargs-long-arguments-and-pause-between-commands

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!