![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | 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 here. |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Can you have var$1 ?
Hi all,
I'm trying to assign values to multiple variables, is there a way i can just change the number of the variable? ie read$num=YES write$num=NO ex$num=YES where the $num can be changed ie. in this instance i have 3 read variables, 3 write variables and 3 ex variables and i'd prefer not to have read1=YES read2=YES read3=NO write1=NO .... etc. Oliver |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
Yes. You might want to do something like this so it's obvious what you're doing - you'll be amazed how confused you can be looking at code again after two years...
Code:
read"$num"=somevalue You do know that ksh supports arrays Code:
set -A Readvar 0 0 0 set -A Writevar 0 0 0 Code:
echo "${Readvar[2]}"
http://www.livefirelabs.com/unix_tip...3/11102003.htm |
|||
| Google The UNIX and Linux Forums |