The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #7 (permalink)  
Old 08-01-2008
Exolon Exolon is offline
Registered User
  
 

Join Date: Aug 2008
Posts: 2
Quote:
Originally Posted by marcpascual View Post
how do i make its output like this?


Code:
a 1
b 2
c 3
d 4
It seems you can't have multiple "x in y" terms in a for loop, so the next best thing is probably to rewrite the loop as an index iterator:

Code:
is=(a b c d)
js=(1 2 3 4)

for ((i = 0; i < 4; i++)) 
	do echo ${is[i]} ${js[i]}
done

It's not as nice, but still relatively easy to read, especially if you define your lists together.