OT: bash positional parameters
Folks
For some reason out of my control I need to pass the name of an env var
to a bash script and then, within said script, determine the value of
that env var.
For example if my script is 'myScript' and assume I've done
$ export INPUTFILE=/tmp/whateverandaday
then how inside myScript do I get the value of INPUTFILE when all I can
pass to the script is the name of the env var, eg
$ ./myScript INPUTFILE
(and no I cannot pass $INPUTFILE directly for another reason [a later
part of the script calls a program which needs the env var name not its
value])
I've tried various combos inside the script like
echo ${$1}
but they don't work (the nearest I can get is
set | grep $1
but that's ugly IMHP)
Cheers!
--
Michael Bane
Atmospheric Physics Group
University of Manchester
Reply to: