GNU Parallel – The command line power tool
slideshare.net
GNU Parallel – The command line power tool
1–10 of 29 posts
Re: GNU Parallel – The command line power tool
#2Re: GNU Parallel – The command line power tool
#3I used to use ppss, which does the core task just as well, but the interface is more complex.
I mostly use these tools to optimize large numbers of PNGs before deployment, using optipng, pngout, and/or my own lossypng. These programs take a while to run so using all my cores gets the job done a lot quicker.
Re: GNU Parallel – The command line power tool
#4Re: GNU Parallel – The command line power tool
#5i use GNU parallel exclusively in place of xargs simply because it has --dry-run.
$ mkdir a
$ cd a
$ touch b c d e
$ find -type f | xargs echo rm
rm ./b ./d ./e ./c
$ ls
b c d e
$ find -type f | xargs rm
$ ls
$Re: GNU Parallel – The command line power tool
#6i use GNU parallel exclusively in place of xargs simply because it has --dry-run.
You can simply re-run that piped to bash (or your shell of choice) to execute commands if you wish (say, if parallel isn't available).
E.g.,
echo foo bar baz | xargs -n1 -t echo ls | bash
... will execute 'ls foo; ls bar; ls baz', while showing the expanded command.Re: GNU Parallel – The command line power tool
#7Recently the developers fixed a major bug for me, that child jobs on other nodes would not be killed when parallel was killed. This was the only thing stopping me from recommending it to my labmates, now there's no reason not to use it!
Re: GNU Parallel – The command line power tool
#8Re: GNU Parallel – The command line power tool
#9i use GNU parallel exclusively in place of xargs simply because it has --dry-run.
wouldn't an "echo" just do the same? $ mkdir a $ cd a $ touch b c d e $ find -type f | xargs echo rm rm ./b ./d ./e ./c $ ls b c d e $ find -type f | xargs rm $ ls $
$ touch 'Ham
Jam
Spam'
$ touch 'J.R. "Bob" Dobbs'
$ find . -type f -print0 | parallel -n1 -0 --dry-run echo
echo ./Ham'
'Jam'
'Spam
echo ./J.R.\ \"Bob\"\ Dobbs
$ find . -type f -print0 | xargs -n1 -0 echo echo
echo ./Ham
Jam
Spam
echo ./J.R. "Bob" Dobbs
For my own "dry runs", though, I've always preferred passing the command line to #include
int main(int argc, char* argv[]) {
char** argp;
int i;
printf("argc = %d\n", argc);
for (i = 0, argp = argv; *argp != 0; ++argp, ++i) {
printf("argv[%d] = %s\n", i, *argp);
}
return 0;
}
to remove all reasonable doubt.