I am trying to combine two arrays into one, like a zipper. I have difficulty making this happen.
array1=(one three five seven) array2=(two four six eight)
I tried using nested for loops but can't figure it out. I do not want the output to be 13572468, but 12345678.
The script I'm working on is here ( http://ix.io/iZR ) .. but it clearly doesn't work as intended. I either get the entire array2 (e.g. 124683), or just the first index, as if the loop weren’t working (e.g. 12325272).
So how do I get the output:
one two three four five six seven eight
with the two above arrays?
Change: I managed to solve this with two for and paste loops ( http://ix.io/iZU ). It would still be interesting to see if anyone has a better solution. So if you have time, please take a look.
arrays bash zsh
Almehdi
source share