Output disk size in GB only. Giga Bytes only.
Not MB. Not Mega Bytes.
Not TB. Not Tera Bytes.
Tested thus far:
sudo blockdev --getsize64 /dev/sda
1000204886016
sudo blockdev --getsize64 /dev/sda |bc -l |awk '{print $1/1000000000}'
1000.2
sudo blockdev --getsize64 /dev/sda |bc -l |awk '{print $1/1000000000}' |numfmt --field=1- --format=%.0f --invalid=ignore
1001
But above 1001
output is a rounding error.
1000
is ideal output, meaning 1000 GB
disk size.
Question1:
How to fix above rounding error?
Question2:
What is a more elegant way or shorter way versus 120 characters below:
sudo blockdev --getsize64 /dev/sda |bc -l |awk '{print $1/1000000000}' |numfmt --field=1- --format=%.0f --invalid=ignore
.
.
using:
neofetch --stdout |grep 'OS:'
OS: Kubuntu 22.04.3 LTS x86_64
—