1

please advice what is wrong with my syntax ( I use it in my bash script )

export CALC=3.4373
python -c 'print CALC > 2.2'

Traceback (most recent call last):

File "<string>", line 1, in ?

NameError: name 'CALC' is not defined

should get True

4

Don't use ''. It doesn't parse bash variables.

What you want is: python -c "print ${CALC} > 2.2"

  • 1
    alternately python -c 'import os; print os.environ["CALC"] > 2.2' – iruvar Dec 15 '16 at 14:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.