Pages

lundi 13 février 2012

find int, output a string with a format

set a = 26400.24567

--- find the integer of the variable and then the digital part
echo $a | awk '{print $0-int($0)}'

-----multiple the digital parts with a constant 86400
echo $a | awk '{print $0-int($0)}' | awk '{print $0*86400}'

---- output with a format
echo $a | awk '{print $0-int($0)}' | awk '{print $0*86400}' | awk '{printf ( "%12.5f" ,$0)}'
"f" should not be omitted which identifies the float number, not int



Aucun commentaire:

Enregistrer un commentaire