Home » Infrastructure » Unix » How can we read multiple values from For Loop in Unix
How can we read multiple values from For Loop in Unix [message #277329] Mon, 29 October 2007 11:04 Go to next message
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 #277335 is a reply to message #277329] Mon, 29 October 2007 11:33 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
You are using the wrong tool for the job & are now paying the price.

>its urgent
Please explain why it is urgent for Me to solve this problem for YOU.

you could try using awk or cut
Re: How can we read multiple values from For Loop in Unix [message #277337 is a reply to message #277335] Mon, 29 October 2007 11:51 Go to previous messageGo to next message
bholaimmu
Messages: 35
Registered: October 2007
Member
Thx for ur help...

actually I want to moved those 2 columns ( values ) to 2 different locations.

do
file_out=`echo $x`
echo "File is $file_out"
cp $file_out <path>
done

I have to columns in $x and I want to copy those columns to 2 different locations.

Thx N Regs,
Immu
Re: How can we read multiple values from For Loop in Unix [message #277341 is a reply to message #277337] Mon, 29 October 2007 12:14 Go to previous messageGo to next message
Michel Cadot
Messages: 68625
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
This is not an Unix forum this is an ORACLE forum dedicated to Unix specific issue.
Post your shell question in a Unix forum.

Regards
Michel
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 Go to previous message
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



Previous Topic: shmmax - memory chunks
Next Topic: File Not Found Error
Goto Forum:
  


Current Time: Fri Mar 29 03:57:50 CDT 2024