How can we read multiple values from For Loop in Unix [message #277329] |
Mon, 29 October 2007 11:04 |
bholaimmu
Messages: 35 Registered: October 2007
|
Member |
|
|
Hi,
How can we use multiple values separately in Do...DONE from For Loop which we have fetched from sql script in Shell Script.
For example; We got 2 columns in x ( for x in `sqlplus -s .... ). Now I want to copy both columns to 2 different locations. So How can I do that?
Plz help me....its urgent
Thx a lot,
Immu.
|
|
|
|
|
|
Re: How can we read multiple values from For Loop in Unix [message #277601 is a reply to message #277341] |
Tue, 30 October 2007 14:20 |
andrew again
Messages: 2577 Registered: March 2000
|
Senior Member |
|
|
If you have space as delimiter, you can just use "read".
Using KSH:
#Note that there are more tokens in the output than
#variables, so V2 catches everything till the end of the line.
mybox> echo "one two three" | read V1 V2; echo V1=$V1 V2=$V2
V1=one V2=two three
mybox> echo "one two three" | read V1 V2 junk; echo V1=$V1 V2=$V2
V1=one V2=two
|
|
|