繁体   English   中英

Linux - 有没有办法获取目录的文件大小,但只包括最后修改/创建日期为 x 的文件?

[英]Linux - is there a way to get the file size of a directory BUT only including the files that have a last modified / creation date of x?

根据标题,我试图找到一种方法来获取目录的文件大小(使用 du),但只计算在特定日期之后创建(或修改)的目录中的文件。

是否可以使用命令行完成?

谢谢:)

来自@Bodo 的评论。 使用 GNU 查找:

find directory/ -type f -newermt 2021-11-25 -printf "%s\t %f\n" | \
awk '{s += $1 } END { print s }' | \
numfmt --to=iec-i
  1. finddirectory/中查找(更改此内容
  2. 查找文件 ( -type f )
  3. 修改时间比 2021-11-25 ( -newermt ) 更新的 (更改此)
  4. 并在每一行输出文件的大小( %s
  5. 将所有尺寸与awk {s += $1 }
  6. 打印结果END { print s }
  7. 使用numfmt--to=iec-i将字节值格式化为人类可读

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM