![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | 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 and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| passing a variable inside a variable to a function | KingVikram | UNIX for Dummies Questions & Answers | 2 | 01-14-2008 08:28 PM |
| how to merge two variable in one variable with space between them? | jaydeep_sadaria | Shell Programming and Scripting | 2 | 12-15-2007 02:23 AM |
| Replace variable with a user defined variable | ce124 | Shell Programming and Scripting | 1 | 04-15-2007 03:56 PM |
| Export command giving Variable Name vs the Value set for the Variable | ParNone | UNIX for Dummies Questions & Answers | 2 | 04-03-2006 12:43 PM |
| ksh: A part of variable A's name is inside of variable B, how to update A? | pa3be | Shell Programming and Scripting | 4 | 03-30-2005 12:29 PM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Referencing variable using another variable
Hello, I am new to shell scripting so this might be a simple question...also, please excuse me if this is a topic discussed before.
I have declared a bunch of variables as such: Host_1=32 Host_2=33 Host_3=34 temp=1 numUsers=4 Now, I am trying to go through a loop to access each of these variables. I have established a while loop like so: while [ $temp -le numUsers] do echo "Host 1 = $Host_"$temp"" temp='expr $temp + 1' done Now this obviously is incorrect, as it looks for a variable called Host_ and doesn't find it, leaving me with only the value of temp being printed. Is there a way to have it so Host_1 is printed with temp=1? I looked into using an array but I figure there might be a quick solution to this. |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|