I already know how to generate pairs by taking one variable from each of a set of arrays, as such:
#!/bin/bash
dir1=(foo baz) # Not ideal: Want inputs to be dir1=(foo bar); dir2=(baz bat) instead
dir2=(bar bat)
for i in "${!dir1[@]}"
do
echo "Comparing ${dir1[i]} to ${dir2[i]}"
done
Produces the following output.
Comparing foo to bar
Comparing baz to bat
Is there a way to do this loop with foo bar
on the same line and baz bat
on it's same line? As follows.
pair1=(foo bar)
pair2=(baz bat)
...
pairN=(qux quux)
...
do
# then, inside the loop, compare the pair
done