How to get df linux command output always in GB [closed]
Asked Answered
M

2

67

How to get df linux command output always in GB always? ie. I want below 34MB to be displayed in GBs

Filesystem            Size  Used Avail Use% Mounted on
/ttt/pda1              21G   20G   34M 100% /

How can this be achieved ?

Thanks in advance.

Mottled answered 6/6, 2013 at 12:25 Comment(0)
D
124

You can use the -B option.

Man page of df:

-B, --block-size=SIZE use SIZE-byte blocks

All together,

df -BG
Dehumidifier answered 6/6, 2013 at 12:27 Comment(0)
G
6

If you also want it to be a command you can reference without remembering the arguments, you could simply alias it:

alias df-gb='df -BG'

So if you type:

df-gb

into a terminal, you'll get your intended output of the disk usage in GB.

EDIT: or even use just df -h to get it in a standard, human readable format.

http://www.thegeekstuff.com/2012/05/df-examples/

Gaberlunzie answered 6/6, 2013 at 12:34 Comment(3)
-g is not an valid optionMottled
@Mottled Ah, well, perhaps then using fedorqui suggestion of df -BG and aliasing that for ease of use.Gaberlunzie
@Mottled I've updated my answer to reflect the correction of my derp.Gaberlunzie

© 2022 - 2024 — McMap. All rights reserved.