To the best of my knowledge, there is no way to rename a variable at all.
I'm assuming you want to change "PWD" to "pwd" or something along those lines.
You can very easily say "pwd=$PWD" and refer to $pwd throughout the rest of your script, but "$pwd" is always going to have the value it had when you ran the assignment statement.
If $PWD changes (say when you cd to another directory), $pwd is NOT going to follow it.
In the more general case, there is no way to cause a program/script to use a different variable name except by changing the source code (and recompiling if it's a binary).
You might want to post why you want to do this. Usually, when people want to do something impossible, what they want it FOR is pretty reasonable, that's just not the right way to do it.
Post the problem you were trying to solve by renaming a variable and the odds are medium good someone can suggest a workable alternative.
Good luck,
CHL
|