I'm trying to match specific individual strings together. For example, I'd like the following to be paired:
file1 and 123.jpg file2 and 432.jpg file3 and 345.jpg
Currently, I'm using the following inefficient method that matches all possibilities between the two lists:
declare -a name1=("file1" "file2" "file3")
declare -a name2=("123.jpg" "432.jpg" "345.jpg")
for y in "${name1[@]}"
do
for x in "${name2[@]}"
do
echo $y$x
done
done
This script provides the following output: file1123.jpg file1432.jpg file1345.jpg file2123.jpg file2432.jpg file2345.jpg file3123.jpg file3432.jpg file3345.jpg
How can I have only the desired pairs matched so that the output looks like the following: file1123.jpg file2432.jpg file3345.jpg