Hatjhie
Hatjhie

Reputation: 1365

XARGS Long Arguments and Pause Between Commands

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?

Upvotes: 1

Views: 904

Answers (1)

Charles Duffy
Charles Duffy

Reputation: 295687

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

Upvotes: 3

Related Questions