0

Let's take this through example. An example ksh script is as below:

ab=123 c=a d=b echo "${c}${d}" # prints ab, but need to print contents of $ab ie. 123 echo "$ab" # prints content of $ab i.e. 123 

How can I print content of varible formed through "${c}${d}" i.e. content of $ab thus formed

2 Answers 2

2

If you have ksh93 then you can use the nameref feature (from here:

# ab=123 # c=a # d=b # typeset -n ref=$c$d # echo "${!ref} = ${ref}" ab = 123 
Sign up to request clarification or add additional context in comments.

Comments

1

You may use eval to achieve this:

eval y='$'${c}${d}; echo $y 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.