My current script is giving output with many decimal places. Is there any way to get only 1 place in the output?
# cat sample
HDD Used: 15.0223T
HDD Total: 55.9520T
# cat sample | awk ' /HDD Total/ { hdd_total=$NF }
/HDD Used/ { hdd_used=$NF }
END {
used=hdd_total-hdd_used
print "cal =" used}'
Current Output
cal =40.9297
Required output
cal =40.9
---> With only one decimal
Getting error for this
# isi storagepool list -v| grep -i 'HDD Total:' | awk '{print "HDD Total=%.1f", $NF -1 " TB" }'
HDD Total=%.1f 54.952 TB
#cat isistorage1
7.332T n/a (R) 13.01% (T)
# cat isistorage1 | awk '{ print "Snapshot USED=", $1}'
Snapshot USED= 7.332T
awk '{ printf "Snapshot USED=%.1f\n" $1}'
– Shanker Aug 02 '17 at 10:01$1
has taken in yourawk
command? it's a floating point value? what this commandtail -n -1 |
gives in output in your command? – αғsнιη Aug 02 '17 at 10:10$1
should be an argument toprintf
add a comma and it should work – Thor Aug 02 '17 at 10:17printf
, notprint
– Jeff Schaller Aug 02 '17 at 14:02