#!/bin/sh FLOAT=1234.567 INT=${FLOAT/\.*} echo $INTWe replace dot and all that follows it with nothing. Notice that this truncates (does not round).
Programming Tips - How do I convert a floating point number into an integer in bash?
Date: 2008jan4
Language: bash
Q. How do I convert a floating point number into an integer in bash?
A. Use the powerful ${} construct: