0

I have a scenario in which I need to execute the below statement.

air sandbox run $AI_PLAN/Sam_22.plan

For the above command AI should be fetched from a command.

> echo $PREFIX
AI

I tried the below ways

air sandbox run $`echo $PREFIX`_PLAN/Sam_22.plan

returned error : File not found

dollar_prefix=$`echo $PREFIX`
air sandbox run ${dollar_prefix}_PLAN/Sam_22.plan

returned error : File not found

Please let me know where am I going wrong in the above coding.

0

3 Answers 3

1

You're going to need to eval something:

PREFIX=AI
AI_PLAN=some_directory
eval directory=\$${PREFIX}_PLAN
air sandbox run $directory/Sam_22.plan
Sign up to request clarification or add additional context in comments.

Comments

0

try using command substitution:

$(command ...)_PLAN

Lets suppose the program make_prefix is in your path. Then:

> make_prefix
AI
> echo $(make_prefix)
AI
> echo $(make_prefix)_PLAN
AI_PLAN

2 Comments

Hi Foo Bah, I did not understand clearly can you please eloborate.
Hi Foo, this did not work out it is giving error message.Thank you.
0

It unclear what you actually want to have happen, but I can guess that you probably want something like

air sandbox ${${PREFIX}_PLAN}/Sam_22.plan

This will take the value of the variable PREFIX (AI in your case?) and append a _PLAN, and use THAT as the name of a variable to fetch

1 Comment

Hi Chris, Thanks for answering I am getting below error > echo ${PREFIX} AI > echo ${PREFIX}_PLAN AI_PLAN > echo ${${PREFIX}_PLAN} -ksh: syntax error: `!' unexpected

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.