Let’s say, I have 3 variables, A=1, B=2, C=3 and finally a last variable containing the name of either of them (VAR=A). Is it possible to call A, B, C based on VAR’s content without ‘if’s?
Like echo "${$VAR}"?
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.
Yes.
There is also a bash-only way of doing this, using indirect reference: