![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| foreach loop + 2 variables | JamesGoh | Shell Programming and Scripting | 3 | 06-04-2008 04:36 AM |
| using variables outside a while loop | Tornado | Shell Programming and Scripting | 2 | 02-09-2007 01:26 AM |
| adding variables for, for loop | jazz | High Level Programming | 3 | 03-13-2006 04:23 AM |
| Writing to variables within a loop | Sniper Pixie | UNIX for Dummies Questions & Answers | 0 | 03-02-2006 09:11 AM |
| for loop with multiple variables ? | fosterian | Shell Programming and Scripting | 3 | 03-01-2004 05:15 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
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 |
|
||||
|
Thanks, I need to re-qualify my question:
what if its not a number and you can't do math on it? e.g. list1: mary eve delilah list2: joseph adam samson output: mary joseph adam eve samson delilah for i in `cat list1`; ... for j in `cat list2`; ... do ... print $i $j ... done any way around this? |
|
||||
|
Quote:
![]() Code:
paste -d ' ' list1 list2 Last edited by danmero; 07-31-2008 at 12:40 AM.. |
|
|||||
|
Quote:
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|