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 -->
  #1 (permalink)  
Old 07-30-2008
marcpascual marcpascual is offline
Registered User
  
 

Join Date: Sep 2005
Posts: 35
SH: two variables in for loop

Hi, say I have a simple sh script like this:


Code:
for i in a b c d
        do
                for j in 1 2 3 4
                        do
                                echo "$i $j"
                        done
        done

and the output is


Code:
 a 1
 a 2
 a 3
 a 4
 b 1
 b 2
 b 3
 b 4
 c 1
 c 2
 c 3
 c 4
 d 1
 d 2
 d 3
 d 4

how do i make its output like this?


Code:
a 1
b 2
c 3
d 4

TIA