![](/img/trans.png)
[英]how to copy current date files or particular date files in linux using rsync command?
[英]Calculating the total size of all files from a particular date to till date using find command
我有一个包含多个子文件夹的文件夹。 需要使用 find 命令计算从特定日期到截止日期的所有文件的总大小。 我尝试使用以下命令。 不工作。
find . -type -f -newerat 2020-01-05 ! -newerat 2020-02-10
问候
你写的命令几乎就是我们需要的一切。
我们首先列出要计算其大小的所有文件。
$ find . -type f -newerat 2020-02-01 ! -newerat 2020-02-11
./c/1
./a/1
./a/3
./a/2
./b/1
./b/2
这为我们提供了要考虑的所有文件的列表。 我们现在需要做的是获取每个文件的大小。 正如@XrXca 在评论中所说,我们可以使用 find 的printf
选项来获取每个文件的大小(以字节为单位)。
$ find . -type f -newerat 2020-02-01 ! -newerat 2020-02-11 -printf="%s\\n"
4
4
4
4
4
4
这为我们提供了一个很好的文件大小列表。
现在我们只需要总结一下。 为此,我们可以使用一点 awk:
$ find . -type f -newerat 2020-02-01 ! -newerat 2020-02-11 -printf="%s\\n" | awk '{s+=$1} END {print s}'
24
这是过滤文件的累积大小,以字节为单位。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.