|
Home > Archive > Unix questions > November 2006 > Question on Variable Reference
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Question on Variable Reference
|
|
| ExecMan 2006-11-28, 1:33 am |
|
Hi all,
I'm not a Unix genius, but I need a bit of help here.
I have some variables in a script. The variables are assigned values
like this:
Mon="TRSAT6.12022006,TRSAT5.12022006"
Tue="TRSUN4.12312006,TRSAT4.12022006"
..
..
..
Additionally, I grab the day of the week from the system: wday=`date
+%a`
What I want is to be able to reference the value of variable $Mon,
$Tue, etc by using the value in $wday.
So, as the weekday changes, I can grab the proper variable value. If I
say fld=$wday, I get the weekday, not the value of $Mon or $Tue.
So, it is almost like a value of a value......
Can this be done???
Thanks!
| |
| Bit Twister 2006-11-28, 1:33 am |
| On 27 Nov 2006 19:09:34 -0800, ExecMan wrote:
>
> Hi all,
>
> I'm not a Unix genius, but I need a bit of help here.
>
> I have some variables in a script. The variables are assigned values
> like this:
>
> Mon="TRSAT6.12022006,TRSAT5.12022006"
> Tue="TRSUN4.12312006,TRSAT4.12022006"
> .
> .
> .
>
> Additionally, I grab the day of the week from the system: wday=`date
> +%a`
>
> What I want is to be able to reference the value of variable $Mon,
> $Tue, etc by using the value in $wday.
>
> So, as the weekday changes, I can grab the proper variable value. If I
> say fld=$wday, I get the weekday, not the value of $Mon or $Tue.
>
> So, it is almost like a value of a value......
>
> Can this be done???
case $wday in
"Mon")
_day=$Mon
;;
"Tue")
_day=$Tue
;;
| |
| ExecMan 2006-11-28, 7:30 am |
|
Bit Twister wrote:
> On 27 Nov 2006 19:09:34 -0800, ExecMan wrote:
>
> case $wday in
> "Mon")
> _day=$Mon
> ;;
> "Tue")
> _day=$Tue
> ;;
> .
> .
> .
> .
> .
> esac
>
> echo $_day
Thank you very much!!
| |
| Bill Marcum 2006-11-28, 7:30 am |
| On 27 Nov 2006 19:09:34 -0800, ExecMan
<johndoe@mtekusa.com> wrote:
>
> Hi all,
>
> I'm not a Unix genius, but I need a bit of help here.
>
> I have some variables in a script. The variables are assigned values
> like this:
>
> Mon="TRSAT6.12022006,TRSAT5.12022006"
> Tue="TRSUN4.12312006,TRSAT4.12022006"
> .
> .
> .
>
> Additionally, I grab the day of the week from the system: wday=`date
> +%a`
>
> What I want is to be able to reference the value of variable $Mon,
> $Tue, etc by using the value in $wday.
>
> So, as the weekday changes, I can grab the proper variable value. If I
> say fld=$wday, I get the weekday, not the value of $Mon or $Tue.
>
> So, it is almost like a value of a value......
>
eval fld=\$$wday
--
This TOPS OFF my partygoing experience! Someone I DON'T LIKE is
talking to me about a HEART-WARMING European film ...
|
|
|
|
|