Loop over tuples in bash?

后端 未结 12 1509
说谎
说谎 2020-12-04 21:00

Is it possible to loop over tuples in bash?

As an example, it would be great if the following worked:

for (i,j) in ((c,3), (e,5)); do echo \"$i and $         


        
12条回答
  •  眼角桃花
    2020-12-04 21:22

    Using GNU Parallel:

    parallel echo {1} and {2} ::: c e :::+ 3 5
    

    Or:

    parallel -N2 echo {1} and {2} ::: c 3 e 5
    

    Or:

    parallel --colsep , echo {1} and {2} ::: c,3 e,5
    

提交回复
热议问题