![]() |
|
|
|
|
|||||||
| 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 |
| adding values with a loop | hcclnoodles | Shell Programming and Scripting | 1 | 05-27-2008 03:42 AM |
| How to use array values after the loop. | Devesh5683 | Shell Programming and Scripting | 1 | 05-13-2008 04:38 PM |
| Loop through only the distinct values in a file | pbekal | Shell Programming and Scripting | 2 | 02-06-2008 02:47 PM |
| Help In Calculation of large values in loop | sandeepb | Shell Programming and Scripting | 6 | 09-13-2007 05:02 AM |
| For Loop and concetnating values in a variable | samit_9999 | UNIX for Dummies Questions & Answers | 21 | 10-03-2006 11:06 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
getting values from variable in a loop
I have a set of variables:
f1="./someFolder" . . f10="./someOtherFolder" And I'm trying to use the following loop for (( i = 0; i <= 10; i++ )) do temp=f$i done I'm trying the get the values from my set of variable to make directories, but I can't seem the get those value from temp. I've tried ${$temp}, and a lot of combinations of brackets and quotes, if there a way of doing this? Thank you. Last edited by kriuz; 01-22-2008 at 11:57 AM. |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
First glance, you have temp=f$one ($1), instead of temp=f$eye (f$i)
|
|
#3
|
|||
|
|||
|
my bad, i meant to post it with an "i", but the question still stands, do you have any suggestions?
|
|
#4
|
||||
|
||||
|
well, yeah
1.- proof read before you post, and use code tags. 2.- post the entire script. The way it is, I don't know what shell you are using (figured out it is bash, because that syntax doesn't work in korn) and I have no idea what you are doing after declaring temp. Anyway, here's a better solution using arrays in korn: Code:
# cat tester
#!/usr/bin/ksh
set -A FOLDERS folder1 folder2 folder3 folderwhatever
for x in $(echo ${FOLDERS[@]}); do
echo $x
done
# ./tester
folder1
folder2
folder3
folderwhatever
|
||||
| Google The UNIX and Linux Forums |