こんなときに使う
シェルで、df
コマンドや ls -l
コマンド打つと、数値が大きいときに見づらい。
具体的にはこれ。
willow:~$ df Filesystem 512-blocks Used Available Capacity iused ifree %iused Mounted on /dev/disk1s1 976695384 369869584 599130216 39% 2137876 9223372036852637931 0% /
おまけに容量が512バイト単位で数えられる・・・もう一個桁上げてほしい。
これをなんとかしたい。
オプションをつける
オプションをつけると見やすくなる。
-k
にすると、1キロバイト単位になる
Filesystem 1024-blocks Used Available Capacity iused ifree %iused Mounted on /dev/disk1s1 488347692 184936208 299563692 39% 2137901 9223372036852637906 0% /
-g
にすると、1ギガバイト単位になる
willow:~$ df -g Filesystem 1G-blocks Used Available Capacity iused ifree %iused Mounted on /dev/disk1s1 465 176 285 39% 2137914 9223372036852637893 0% /
-h
は、人間が読める単位にする。
willow:~$ df -h Filesystem Size Used Avail Capacity iused ifree %iused Mounted on /dev/disk1s1 466Gi 176Gi 286Gi 39% 2137874 9223372036852637933 0% /
基本的に -h
だけで良いと思います。
おまけ:-hの名前の由来
man df
コマンドを読んで見る
-H "Human-readable" output. Use unit suffixes: Byte, Kilobyte, Megabyte, Gigabyte, Terabyte and Petabyte in order to reduce the num- ber of digits to three or less using base 10 for sizes. -h "Human-readable" output. Use unit suffixes: Byte, Kilobyte, Megabyte, Gigabyte, Terabyte and Petabyte in order to reduce the num- ber of digits to three or less using base 2 for sizes.
"Human-readable" output.
人間が読めるようにってことですね。