df -hとdfcの違い

df -hとdfcの違い

dfcとの間に使用されるサイズに違いがあるのはなぜですかdf -h

$ df -h
Dateisystem    Größe Benutzt Verf. Verw% Eingehängt auf
/dev/sda7        64G     51G   11G   83% /
none            4,0K       0  4,0K    0% /sys/fs/cgroup
udev            3,9G    4,0K  3,9G    1% /dev
tmpfs           801M    1,5M  799M    1% /run
none            5,0M       0  5,0M    0% /run/lock
none            4,0G    148K  4,0G    1% /run/shm
...

$ dfc

FILESYSTEM  (=) USED      FREE (-) %USED AVAILABLE     TOTAL MOUNTED ON 
/dev/sda7   [=================---]   83%     10.6G     63.9G /
none        [--------------------]    0%      4.0K      4.0K /sys/fs/cgroup
udev        [=-------------------]    0%      3.9G      3.9G /dev
tmpfs       [=-------------------]    0%    798.7M    800.1M /run
none        [--------------------]    0%      5.0M      5.0M /run/lock
none        [=-------------------]    0%      3.9G      3.9G /run/shm
...

私は3.9を4に丸め、次に4,0を表示しません。それは私には言いません。

ベストアンサー1

単に「丸め」するものではありません。 dfc(および)は、最も近い数値表現に丸めdiられた値を印刷します。df戻る

質問はcoreutilsのバージョンを指定しません。バージョン8.13(Debian 7)に基づいて回答していますが、8.25でも同じ結果が表示されます。

~から-hオプション存在するdf.c

    case 'h':
      human_output_opts = human_autoscale | human_SI | human_base_1024;
      output_block_size = 1;
      break;

gnulibの "human.c"には後続のコードがあります(こんにちは) によって使用される丸めの種類が決まります。ヒューマンオプションは変更されないため天井代わりに地面または丸め最も近い値で。その理由はゼロが発生するためです。列挙値天井の場合:

  /* Unless otherwise specified these options may be ORed together.  */

  /* The following three options are mutually exclusive.  */
  /* Round to plus infinity (default).  */
  human_ceiling = 0,
  /* Round to nearest, ties to even.  */
  human_round_to_nearest = 1,
  /* Round to minus infinity.  */
  human_floor = 2,

おすすめ記事