I will be reading variables in from a config file. Say, for instance, that the file looks like this:
cfg1=hello
cfg2=there
My script will read that in, so it will have variables names $cfg1 and $cfg2. I now want to determine if the command line argument matches one of the defined variables. I.e., if I execute script.sh cfg1 I want my if statement to pass, but if I execute script.sh cfg3 it should fail.
I'm aware of the \$$varname syntax, but frankly I can't figure out how it works. I've tried:
if [[ \$$1 ]]
but that's always passes.