Regarding this post: Sum up numbers with KB/MB/GB/TB/PB... suffixes
I have a few machines that have older Debian version on them and can't be upgraded to a newer version of Debian, which means that the
coreutils package does not contain
numfmt. I tried to find a another way to get it for it
(machine is Debian 7.6), but I am forced to use another way to get my disk size.
I'm currently using the following:
lshw -class disk -class storage | grep size: | cut -d "(" -f2 | cut -d ")" -f1 | sed -e 's/[^0-9]/ /g' | paste -sd+ | bc
I can easily get the size, but I am in need of getting GB/TB or even MB to it also.
If I use:
lshw -class disk -class storage | grep size: | cut -d "(" -f2 | cut -d ")" -f1
On my other machines I'd get for an example:
2TB 2TB 2TB
Is there a way to save the word after the numbers in a variable and later print it out?
Also, to eliminate the chance of a machine to have multiple drives with different sizes like
500GB 2TB 3TB
This way my command sadly does not work, it would give you