Jonas
Jonas

Reputation: 3184

How to echo a floating point number within a bash script including the leading 0 before the dot

I am echoing a floating point variable. The results looks as follows:

.4983385178

I am using echo -e "$var". How can I tell echo also to print the 0 before the dot:

0.4983385178

Thanks in advance! Jonas

Upvotes: 2

Views: 5156

Answers (1)

kev
kev

Reputation: 161874

printf may help:

$ printf '%.10f\n' .4983385178
0.4983385178

Upvotes: 6

Related Questions