Quotes issue in bash while executing python cmd line

Question:

i am running a python command per below in bash env, it runs fine :

python -c "from ami_management import cleanup; cleanup.main(['10', 'ctm'])"

But when i am passing variables :

amis_to_retain="10"
ami_prefix="ctm"
python -c "from ami_management import cleanup;cleanup.main([$amis_to_retain, $ami_prefix])"

then it fails.
Somehow not able to figure out how to pass these variables with single quotes instead of double quotes.

Please suggest.

Asked By: sharad jain

||

Answers:

You need to put quotes inside quotes.

python -c "from ami_management import cleanup;cleanup.main(['$amis_to_retain', '$ami_prefix'])"
Answered By: FelipeC
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.