1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

問題

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でファイルを見つけ、右クリック→「情報を見る」

image.png

選択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
1
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?