0

I have a variable set as:

X="AA BB CC DD EE"
Y="AA DD EE"

Then each value have its own values assigned as below:

AA="after"
BB="before"
CC="care"
DD="driver"
EE="escape"

Then I need to loop through these variables and need to get its corresponding values to be printed.

for myloop in `echo $Y`
do
    # Now I need to print each variable  
    echo ${$myloop} # if its value is number then I can use ((myloop)) to print it
done

The output should be:

after
driver
escape

How can I achieve this using shell script? I am not using any array.

Jagath
  • 328
  • 5
  • 19

0 Answers0