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.
Answers:
You need to put quotes inside quotes.
python -c "from ami_management import cleanup;cleanup.main(['$amis_to_retain', '$ami_prefix'])"
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.
You need to put quotes inside quotes.
python -c "from ami_management import cleanup;cleanup.main(['$amis_to_retain', '$ami_prefix'])"