I'm writing a shell-script for linux terminal. I want to be able to input variable names on a prompt. For example:
test="Monkey in the middle..." read -p "Enter input: " input echo $input
Enter input: $test $test
I want to be able to input "$test" during the
read -p prompt segment of the script and have the script echo "Monkey in the middle..." at the end instead of echo-ing "$test" as it does now.
How would I go about doing that?
Using the answers provided to me here and in this thread (a big thanks to the contributors and commentators!), I managed to piece together this line which worked very well for me:
newvariable="$(eval echo $input)"
Be, advised, I was warned more than once that using eval may pose a security risk. Keep that in mind if you opt for this solution.