我用 寫了一個小備份腳本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
這應該消除對檔案系統區塊大小或其他元資料的依賴。