I use code in !/bin/sh like this:
LIST1="mazda toyota honda"
LIST2="2009 2006 2010"
for m in $LIST1
do
echo $m
done
As you can see this currently prints out only the make of the car. How can I include the year to each "echo" based on the same positions so that I get results like:
mazda 2009
toyota 2006
honda 2010
?
Assuming bash
array1=(mazda toyota honda)
array2=(2009 2006 2010)
for index in ${!array1[*]}
do
printf "%s %s\n" ${array1[$index]} ${array2[$index]}
done
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With