Jul 15, 2007 #1 uuperl Programmer Feb 20, 2006 33 US Hi, I need print out like this: i=one two three four five p=a b c d e output should be: one a two b three c four d five e here is what I have but is not doing the trick: for i in one two three four five do for p in a b c d e do echo $i $p done done Thanks!
Hi, I need print out like this: i=one two three four five p=a b c d e output should be: one a two b three c four d five e here is what I have but is not doing the trick: for i in one two three four five do for p in a b c d e do echo $i $p done done Thanks!
Jul 15, 2007 #2 TonyGroves Programmer Aug 13, 2003 2,389 IE How is it not doing the trick? It's producing "one a one b one c one d one e two a two b ..", is that right? What you would need is:[tt] for i in 'one a' 'two b' ...[/tt] using one loop instead of two. Upvote 0 Downvote
How is it not doing the trick? It's producing "one a one b one c one d one e two a two b ..", is that right? What you would need is:[tt] for i in 'one a' 'two b' ...[/tt] using one loop instead of two.
Jul 15, 2007 #3 stefanwagner Programmer Oct 19, 2003 2,373 DE Code: i=(one two three) p=(a b c) for n in $(seq 0 2) ; do echo ${i[n]} ${p[n]} ; done don't visit my homepage: http://home.arcor.de/hirnstrom/bewerbung Upvote 0 Downvote
Code: i=(one two three) p=(a b c) for n in $(seq 0 2) ; do echo ${i[n]} ${p[n]} ; done don't visit my homepage: http://home.arcor.de/hirnstrom/bewerbung
Jul 16, 2007 #4 Ogzilal MIS Oct 9, 2003 280 FR Hi, You can use standard shell arguments as the inner loop Code: # set argument list the second collection set a b c d e for i in one two three four five do echo $i $1 shift #shift argument list to left done Upvote 0 Downvote
Hi, You can use standard shell arguments as the inner loop Code: # set argument list the second collection set a b c d e for i in one two three four five do echo $i $1 shift #shift argument list to left done