Originally Posted by musonio
The loop below does it perfectly, but the variables are not exported outside the script.
You might have misunderstood what "export" really does. If you mean, that you want the variables to be visible *after* the script ends, that's impossible.
The script is run into a new subshell, when the script ends, that subshell dies, and all its environment goes to /dev/null.
There's a workaround: read into "source" or the "." dor operator. If you run the script like this:
The script is literally dumped into the current shell, instead of instantiating a new one. Just like if you write the script in the command line, line by line, character by character. Hence, the environment will also belong to the current shell.
I get nothing.
Anyway, that code doesn't do what you think it does. All that does is to define a variable called "echo", with the contents of the "POTATOESX" variable. So, the contents of "$echo" and "$POTATOESX" will be the same.
You probably mean