On Mon, Oct 30, 2023 at 2:22 AM Ole Tange <[email protected]> wrote:
> Is there an easy way to go from:
>
> parallel echo {2} {1} ::: A-BB C-DD ::: E-FF G-HH
>
> to this (where I have to calculate what number {4} would get):
>
> parallel --match '((.)-(..))' \
> echo {4} {1} {3} ::: A-BB C-DD ::: E-FF G-HH
>
> Maybe matched vars should not be called {4} but {m4}; so {2} can keep
> its meaning?
Maybe --match would enable replacement strings {n.m} where:
- n is input source
- m is the regexp capture group
This way {2} is unchanged:
parallel --match '(.)-(..)' --match '(..),(.)' \
echo {}={1}+{2} {1}={1.1}-{1.2} {2}={2.1},{2.2} ::: A-BB C-DD ::: EE,F GG,H
Used with "--header :" it would look like this:
parallel --header : --match '(.)-(..)' --match '(..),(.)' \
echo {}={foo}+{bar} {foo}={foo.1}-{foo.2} {bar}={bar.1},{bar.2} :::
foo A-BB C-DD ::: bar EE,F GG,H
It would make the syntax for the common use case (with a single input
source) a bit longer:
echo 2023-10-29T23:59:59+01:00 |
parallel --match '((....)-(..)-(..))T((..):(..):(..))[-+](..:..)' \
echo YMD={1.1} Y={1.2} M={1.3} D={1.4} HMS={1.5} H={1.6} M={1.7}
S={1.8} Z={1.9}
/Ole