I'm trying to export a variable in this manner:
P="A="X""
echo $P
P=X
export $$P <- can't get this to work, tried a bunch of permutations
Desired out put is then to be effectively 'export A=X' In the example I want to 'export P=X' to be the command I run, however I cannot get it to work correctly
CodePudding user response:
Please try this
P="A=\"X"\"
echo $P
A="X"
CodePudding user response:
How about:
$ P='A="This is a test"'
$ echo "$P"
A="This is a test"
$ eval export "$P"
$ echo "$A"
This is a test