![]() |
|
|
|
|
|||||||
| 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. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Reference Variable | cchaloux | Shell Programming and Scripting | 18 | 10-03-2007 06:58 AM |
| How to reference a variable within sed? | rockysfr | Shell Programming and Scripting | 1 | 06-27-2007 01:04 AM |
| KSH variable substitution | tipsy | Shell Programming and Scripting | 5 | 08-14-2006 02:07 PM |
| Variable Substitution | garak | Shell Programming and Scripting | 2 | 03-16-2006 04:55 PM |
| Substitution in a variable | spragueg | UNIX for Advanced & Expert Users | 3 | 10-18-2001 06:14 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
I can't seem to make what appears to be a simple substitution.
I want to define a list of systems for which daily reports need to be filed systems="systemA systemC systemZ" I then want to run a loop for i in ${systems} Analyze statistics Create the reports mailx |
| Forum Sponsor | ||
|
|
|
|||
|
Sorry - first time on the board and I did not finish my problem before I accidentally hit a key and posted it. Thanks for reply
Here is what I can not do. For each of those systems, I neeed to email the reports using mailx to different recipients. systemA_list="me you" systemB_list="me you him" systemZ_list="you him" Therefore, in the for do loop, I need to use the current value of the systems variable that is being processed to reference the correct ${systems}_list and poulate the mailx command. It is that variable substitution or reference that I can not seem to acheive. it always tells me it can not find systemA_list. Not sure if it even knows I am trying to make it a variable. Thanks Mark |
|
|||
|
With bash, you can use the following construct to use the contents of a variable as the name of another variable, doing in effect a double expansion:
${!systems} If systems contains "systemA_list", then it will instead expand the value of $systemA_list. It sounds like you have to do something like this: system=systemA listname=${system}_list #put name of required variable in $listname list=${!listname} # expand $listname twice, giving the value of $systemA_list |
| Thread Tools | |
| Display Modes | |
|
|