Loop over tuples in bash?

后端 未结 12 1496
说谎
说谎 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:05

    $ echo 'c,3;e,5;' | while IFS=',' read -d';' i j; do echo "$i and $j"; done
    c and 3
    e and 5
    

提交回复
热议问题