[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: GNU Parallel Bug Reports The wierd output from total_jobs function
From: |
Ole Tange |
Subject: |
Re: GNU Parallel Bug Reports The wierd output from total_jobs function |
Date: |
Wed, 25 Sep 2019 20:25:58 +0200 |
On Mon, Sep 9, 2019 at 2:36 PM Daniel Zhang <address@hidden> wrote:
> $ echo -e "A\tB\tC" | parallel echo '{} {= $_=total_jobs() =}'
> A B C 1
> $ echo -e "A\tB\tC" | parallel --colsep '\t' echo '{} {= $_=total_jobs() =}'
> A B C 1 1 1
>
> Why the output of total_jobs() is 1 1 1 ?
It is due to this:
echo -e "A\tB\tC" | parallel --colsep '\t' echo '{} {}'
which is the same as this:
echo -e "A\tB\tC" | parallel --colsep '\t' echo '{} {= =}'
which is the same as this:
echo -e "A\tB\tC" | parallel --colsep '\t' echo '{} {= $_=$_ =}'
The {= =} is evaluated for each argument and with three arguments it
is inserted three times.
So how do you get it only once? This way:
echo -e "A\tB\tC" | parallel --colsep '\t' echo '{} {=1 $_=total_jobs() =}'
Can we make an (semi real) example for the man page where we use
multiple arguments, and the positional argument in a command?
/Ole