INPUT=10
OUTPUT_IN=20
KEYWORD="IN"
echo $OUTPUT_"$KEYWORD"
It should display 20
Mainly I am looking to generate the variable name OUTPUT_IN
How to resolve this?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can use indirection in Bash like this:
However, you should probably use an array or some other method to do what you want. From BashFAQ/006:
And you should avoid using
evalif at all possible. From BashFAQ/048:Bash 4 has associative arrays which would allow you to do this: