I have a .py code that gives me a number which I want to save to some shell variable because I need to use a if/fi loop on that variable. How can I do that? My a.py gives me 1.0 and my condition is sth like: if $x <= 1.5 do sth
I need the .py output to go to $x.
bash
itself can really only perform integer arithmetic – steeldriver Nov 11 '19 at 23:56x=$(python code.py); if (( $(echo "$x <= 1.5" | bc) )); then ...
– glenn jackman Nov 12 '19 at 01:58x=$(python3 -c 'import sys ; print(sys.version[0:3])'); echo $x
– user1404316 Nov 12 '19 at 03:38$(...)
bit) in that comment should contain the shell code necessary to invoke your Python script. So use the command in there that you would normally use to run the Python script. – Kusalananda Nov 12 '19 at 07:43