December 5th, 2012, 11:21 AM
Preserving values with for loop for later use
This is a unix shell script related question. But posting it here since there is no seperate section for Shell scripts.
Below is the issue I am having.
I have a few variables which have certain values in them like
I want to save these values with the help of a for loop in a single variable so that I can use it later,beacuse a few lines down the script, some of these variables get set to a different value and I would like to reset them to the values that I had saved.Can you point out a way without using arrays?
December 5th, 2012, 12:44 PM
Hi, recent versions of bash have one-dimensional arrays, e.g.:
To dereference your values, you'll need curlies around the name of the variable:
With other shells, I don't think it is possible, except perhaps by simulating it using symbolic references.