OpenSUSE shell scripting

Hi, I hope I’m not posting this in the wrong place. I would like to create a script that enables the user to check disk usage of the root folder. Now, I know using df -h / will display this information, but I want it to show the results with Gb showing, instead of just G.
So, if my output is 41G 6.2G 32G 17%, how do I get it to say 41Gb 6.2Gb 32Gb 17% instead?

You realize that by making this change you are making your result
incorrect, right? Gb = gigabit, which is 1/8 of a gigabyte.

Oh well… anyway:

Code:

df -h / | sed -e ‘s/G /Gb /g’


Good luck.

If you find this post helpful and are logged into the web interface,
show your appreciation and click on the star below…

On 2014-03-17, ab <ab@no-mx.forums.opensuse.org> wrote:
> You realize that by making this change you are making your result
> incorrect, right? Gb = gigabit, which is 1/8 of a gigabyte.
>
> Oh well… anyway:
>
> Code:
> --------------------
> df -h / | sed -e ‘s/G /Gb /g’
> --------------------

Doesn’t df -h' express sizes not in gigabytes but gibibytes (cf. df -H)? Not sure if ISO has a gibibit’ but I can’t
see why not…

Good point; I misread last night when I checked seeing only the last bit:

SIZE is an integer and optional unit (example: 10M is 1010241024).
Units are K, M, G, T, P, E, Z, Y (powers of 1024) or KB, MB, … (powers
of 1000).

So yes, the correct way would not be either GB or (as originally
requested) Gb, but rather GiB. As a result these options are now available:

Code:

df -BGB / #print out in GB (gigabytes)
df -BG / | sed -e ‘s/G /GiB /g’ #print in GiB (gibibytes), better
df -BG / | sed -e ‘s/G /Gb /g’ #Print in GiB, labeled Gb, wrong
df -BGB / | sed -e ‘s/GB /Gb /g’ #Relabel from GB to GB, more wrong


Good luck.

If you find this post helpful and are logged into the web interface,
show your appreciation and click on the star below…

On 2014-03-17 10:36, flymail wrote:
> On 2014-03-17, ab <ab@no-mx.forums.opensuse.org> wrote:
>> You realize that by making this change you are making your result
>> incorrect, right? Gb = gigabit, which is 1/8 of a gigabyte.
>>
>> Oh well… anyway:
>>
>> Code:
>> --------------------
>> df -h / | sed -e ‘s/G /Gb /g’
>> --------------------
>
> Doesn’t `df -h’ express sizes not in gigabytes but gibibytes

Yes. So you should express the output as “GiB”, not “G” nor “Gb” :slight_smile:


Cheers / Saludos,

Carlos E. R.
(from 13.1 x86_64 “Bottle” at Telcontar)

On 2014-03-17, Carlos E. R. <robin_listas@no-mx.forums.opensuse.org> wrote:
> Yes. So you should express the output as “GiB”, not “G” nor “Gb” :slight_smile:

Bugzilla GNU for df?

On 2014-03-17 12:22, flymail wrote:
> On 2014-03-17, Carlos E. R. <> wrote:
>> Yes. So you should express the output as “GiB”, not “G” nor “Gb” :slight_smile:
>
> Bugzilla GNU for df?

Sigh.

My feeling is that not all developers want to comply with the current
naming standard. On the other hand, changing that might break scripts
that use the command parsing the output.


Cheers / Saludos,

Carlos E. R.
(from 13.1 x86_64 “Bottle” at Telcontar)