問題
macosでこういった問題が出ている:
% du -b system_raw.img
du: invalid option -- b
usage: du [-Aclnx] [-H | -L | -P] [-g | -h | -k | -m] [-a | -s | -d depth] [-B blocksize] [-I mask] [-t threshold] [file ...]
原因
linuxでのdu
コマンドの実装とは違うようです。確認してみたら:
mac (man du
):
AUTHORS
This version of du was written by Chris Newcomb for 4.3BSD-Reno in 1989.
linux:
# du --version
du (GNU coreutils) 8.30
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by Torbjorn Granlund, David MacKenzie, Paul Eggert,
and Jim Meyering.
回避策
du -b
はファイルのバイト数を確認するコマンドです。故に:
選択1:finderで確認
finderでファイルを見つけ、右クリック→「情報を見る」
選択2:ls -l
を使用
ls -l
も正確にフィアルのバイス数を出力する:
% ls -l system_raw.img
-rw-r--r--@ 1 zyfy staff 3272933376 1 1 2009 system_raw.img
awk
と合わせて、バイト数の値だけを取得:
% ls -l system_raw.img | awk '{print $5}'
3272933376