Home > python > call python in a shell script

call python in a shell script

Problem
Floating point arithmetic in bash is problematic, expr supports integers only for instance.

Solution
Not an optimal solution but it works:

$ python -c "print 5.5*3"
16.5

$ num=`python -c "print 5.5*3"`
$ echo $num
16.5
Categories: python Tags: ,
  1. No comments yet.
  1. No trackbacks yet.

Leave a comment

Design a site like this with WordPress.com
Get started