[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: question about passing complex strings in Parallel
From: |
Ole Tange |
Subject: |
Re: question about passing complex strings in Parallel |
Date: |
Mon, 15 Jul 2024 17:10:08 +0200 |
On Sat, Jun 15, 2024 at 11:32 PM Saint Michael <venefax@gmail.com> wrote:
>
> This is related to parallel, but we can replicate the issue in plain bash.
> in this code:
> data="'1,2,3,4','5,6,7,8'"
>
> # Define the processing function
> process() {
> echo "There are $# arguments."
> echo "They are: $@"
> local job="$1"
> shift
> local a="$1"
> shift
> local b="$1"
> shift
> local remaining="$*"
> echo "Arg1: '$a', Arg2: '$b'"
> }
> process "$data"
>
> how can I get my (a) and (b) arguments right?
> The length of both strings is unpredictable.
> a="1,2,3,4" and b="5,6,7,8""
If we can make a slight change (" <=> ') your input is a quoted CSV-file:
$ export -f process
$ data='"1,2,3,4","5,6,7,8"'
$ echo "$data" | parallel --csv process dummy {}
There are 3 arguments.
They are: dummy 1,2,3,4 5,6,7,8
Arg1: '1,2,3,4', Arg2: '5,6,7,8'
/Ole
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: question about passing complex strings in Parallel,
Ole Tange <=