Bash scripting: convert float to integer

As bash is not able to handle floats the best way is to convert a float number (which is represented as a string, for example an output with awk) into an integer.

To do this [1,2]:
float=1.23
int=${float%.*}

Refs:
[1] Stackexchange.com/Unix & Linux
[2] Linuxquestions.org

Leave a Reply

Your email address will not be published. Required fields are marked *