【问题标题】:How can I determine disk usage of folders of a particular date in bash?如何确定 bash 中特定日期的文件夹的磁盘使用情况?
【发布时间】:2021-11-18 13:16:35
【问题描述】:

每天有数以千计的文件夹和数百个。 如何在 bash 中找出特定日期的文件夹使用了多少磁盘空间?

【问题讨论】:

    标签: date directory disk


    【解决方案1】:

    perl -MPOSIX -e 'for ( grep {-d} glob ( "*" ) ) { print join "\t", strftime("%Y-%m-%d",gmtime((stat)[9])), du -sm $_ }' | grep "<date>" | awk '{s+=$2} END {print s}'

    总结是由 awk-command 完成的。

    我结合了以下帖子的答案:

    1. 文件夹的列表大小及其更改日期 https://unix.stackexchange.com/questions/250898/list-size-of-folders-and-their-changed-dateperl -MPOSIX -e 'for ( grep {-d} glob ( "*" ) ) { print join "\t", strftime("%Y-%m-%d",gmtime((stat)[9]))), du -sh $_ }'
    2. 使用 find 命令计算从特定日期到截止日期的所有文件的总大小 Calculating the total size of all files from a particular date to till date using find command → 在我的环境中不起作用,但结合 1) 和 2) 我可以找到适用于我的环境的解决方案。

    【讨论】:

      猜你喜欢
      • 2022-11-10
      • 2017-12-18
      • 2011-08-04
      • 2019-05-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多