如何始终以 GB 为单位获取 df linux 命令输出

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16962041/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 23:09:00  来源:igfitidea点击:

How to get df linux command output always in GB

linuxdf

提问by Aryan

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

如何始终以 GB 形式获取 df linux 命令输出?IE。我希望以 GB 为单位显示低于 34MB

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

How can this be achieved ?

如何做到这一点?

Thanks in advance.

提前致谢。

采纳答案by fedorqui 'SO stop harming'

You can use the -Boption.

您可以使用该-B选项。

Man page of df:

df 的手册页

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

-B, --block-size=SIZE 使用 SIZE 字节的块

All together,

全部一起,

df -BG

回答by Radai

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.

进入终端,您将获得以 GB 为单位的磁盘使用量的预期输出。

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

编辑:或者甚至只是使用df -h标准的、人类可读的格式来获取它。

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

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