0

Thank you very much in advance for helping!

I have this variables:

scene1=lounge
scene2=bedroom
scene3=bathroom

What I want to do is a loop, and for every file in a particular folder, echo the variable scene#

order=1
for f in $(find $dest_scenes/*.xml -maxdepth 0 )
do
    scene_name=scene$order #scene1, scene2, scene3
    echo $scene_name
done
order=$(expr $order + 1)

Output:

scene1
scene2
scene3

What I would like to:

lounge
bedroom
bathroom

I don't want to get $scene_name, I want to got $($scene_name) if you know what I mean...

Thank you!!!

1 Answer 1

2

That's called variable interpolation. In your case, you could do:

echo ${!scene_name}

See How do I use a variable within a variable for more variations.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.