help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-bash] parallel processing in bash (to replace for loop)


From: Ole Tange
Subject: Re: [Help-bash] parallel processing in bash (to replace for loop)
Date: Wed, 9 May 2012 23:12:38 +0200

On Sat, 4 Feb 2012 16:57:02 -0600,  "Peng Yu" <address@hidden> wrote:

:
> This solution and other solutions (including gnu parallel) suffer the
> problem of not able to understand bash function.

>From GNU Parallel's man page:

    _command_ Command to execute.
     [...]
    The command must be an executable, a script, a composed command,
    or a function. If it is a function you need to export -f the
    function first. An alias will, however, not work (see why
    http://www.perlmonks.org/index.pl?node_id=484296).

So it is not entirely true that GNU Parallel is not able to understand
bash functions, but it _is_ true, that it does not work without the
export. Here is an example:

$ hello=xxx
$ myfun() { echo $hello$1; }
$ myfun 1
xxx1
$ export -f myfun
$ export hello
$ sem --fg myfun 1
xxx1
$ echo 1 | parallel myfun
xxx1

/Ole
-- 
Did you get your GNU Parallel merchandise?
https://www.gnu.org/software/parallel/merchandise.html



reply via email to

[Prev in Thread] Current Thread [Next in Thread]