Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Mailing Lists -> Oracle-L -> RE: Very Simply KSH Question
Unfortunately, the only way I could avoid multiple file reads of the same
file was this :
vFileName='file.ext'
for value in `cat ${vFileName}`
do
x=`echo ${value}|awk -F'|' '{ print $2 }'`
y=`echo ${value}|awk -F'|' '{ print $3 }'`
done
Its unfortunate because it looks a lot like the code you had that you hated. And it does work on Linux
-----Original Message-----
From: Post, Ethan [mailto:Ethan.Post_at_ps.net]
Sent: Tuesday, April 05, 2005 3:03 PM
To: Kevin Lange; carmen.rusu_at_rrc.state.tx.us;
mgogala_at_allegientsystems.com
Cc: oracle-l_at_freelists.org
Subject: RE: Very Simply KSH Question
list is in file
KEY|FOO|WRECK|CAR need to assign field 2 to X, 3 to Y...
I hate...
X=$(cat file | grep "^FOO" | awk -F"|" '{ print $2}') Y=$(cat file | grep "^FOO" | awk -F"|" '{ print $3}') ...
in many scripts I...
grep "^FOO" file | awk -F"|" '{ print $2" "$3" "$$ }' | read X Y Z
that ain't working on ?linux? yall
( perl answers don't count )
-----Original Message-----
From: Kevin Lange [mailto:klange_at_ppoone.com]
Sent: Tuesday, April 05, 2005 2:45 PM
To: 'carmen.rusu_at_rrc.state.tx.us'; mgogala_at_allegientsystems.com; Post,
Ethan
Cc: oracle-l_at_freelists.org
Subject: RE: Very Simply KSH Question
I figure he either ment Delineated or Delimited (in this case delimited
by a
SPACE)
And personally, I would have done it:
list='1 5 7 22'
for value in ${list}
do
echo ${value}
done
Then, at some time in the future, you can replace the setting of 'list'
with
anything from
a call to a function of some type or even a call to a database.
-----Original Message-----
From: Carmen Rusu [mailto:carmen.rusu_at_rrc.state.tx.us]
Sent: Tuesday, April 05, 2005 2:34 PM
To: mgogala_at_allegientsystems.com; Ethan.Post_at_ps.net
Cc: oracle-l_at_freelists.org
Subject: Re: Very Simply KSH Question
Excuse me, what does "deliminated" list mean?
Couldnt find "deliminated" in my Webster...
Thanks,
Carmen Rusu
Odba
>>> Mladen Gogala <mgogala_at_allegientsystems.com> 4/5/2005 2:27:10 PM
>>>
Post, Ethan wrote:
>This works on my Solaris server, when I run on my web host (not sure
>what OS) it will not set X and Y. Both are using ksh. Is this
related
>to ksh versions or is this a stupid way to set multiple variables from
a
>deliminated list?
>
> echo 2 4 | read X Y
> echo $X
>2
> echo $Y
>4
>--
>http://www.freelists.org/webpage/oracle-l
>
>
It is a stupid way to set multiple variables from a deliminated list.
Smart way would be this:
$ let A=2; $ let B=3 $ let C=$A*$B $ echo $C
-- Mladen Gogala Oracle DBA Ext. 121 -- http://www.freelists.org/webpage/oracle-l -- http://www.freelists.org/webpage/oracle-l -- http://www.freelists.org/webpage/oracle-lReceived on Tue Apr 05 2005 - 16:51:33 CDT