ディレクトリ構造のファイル サイズをまとめますか?

ディレクトリ構造のファイル サイズをまとめますか?

で小さなバックアップ スクリプトを作成しましたrsync。ソース ディレクトリと宛先ディレクトリの合計ファイル サイズを比較して、進行状況を監視したいと考えています。 は、duファイル サイズではなくディスク使用量を測定し、ディスク使用量はファイル システムによって異なるため、不正確です。

ディレクトリ構造全体のファイル サイズを要約するにはどうすればよいですか?

答え1

おそらく、--apparent-size次のオプションがduあなたが求めているものを実現するでしょう:

--apparent-size
       print apparent sizes,  rather  than  disk  usage;  although  the
       apparent  size is usually smaller, it may be larger due to holes
       in (`sparse') files, internal  fragmentation,  indirect  blocks,
       and the like

これにより、ファイル システムのブロック サイズやその他のメタデータへの依存がなくなるはずです。

関連情報