[英]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?
as per title I am trying to find a way to get the file size of a directory (using du) but only counting the files in the directory that have been created (or modified) after a specific date.根据标题,我试图找到一种方法来获取目录的文件大小(使用 du),但只计算在特定日期之后创建(或修改)的目录中的文件。
Is it something that can be done using the command line?是否可以使用命令行完成?
Thanks:)谢谢:)
From @Bodo's comment.来自@Bodo 的评论。 Using GNU find:
使用 GNU 查找:
find directory/ -type f -newermt 2021-11-25 -printf "%s\t %f\n" | \
awk '{s += $1 } END { print s }' | \
numfmt --to=iec-i
directory/
( change this ) directory/
中查找(更改此内容)-type f
)-type f
)-newermt
) ( change this ) -newermt
) 更新的 (更改此)%s
) on each line%s
){s += $1 }
{s += $1 }
END { print s }
END { print s }
--to=iec-i
--to=iec-i
将字节值格式化为人类可读
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.