如何使用 Date Range 过滤掉 1GB 或以上的文件。

如何使用 Date Range 过滤掉 1GB 或以上的文件。

任何人都可以建议我脚本或命令来查找大小超过 1 GB 且日期范围如 May 01 到 May 31 的文件。

请帮助我创建脚本或命令。我想移动 5 月 1 日至 5 月 31 日日期范围内的所有文件,其大小超过 1GB。

问候, 比斯瓦吉特

答案1

这对你有用吗?

touch --date "2017-05-01" /tmp/start
touch --date "2017-05-31" /tmp/end
find /path/ -type f -newer /tmp/start -not -newer /tmp/end -size +1G -exec mv "{}" /path/to/new/dir/ \;

你可以将它用作 bash 脚本(例如scriptname.sh /path/to/search/dir /path/to/destination/dir):

#!/usr/bin/env bash

touch --date "2017-05-01" /tmp/start
touch --date "2017-05-31" /tmp/end
find "$1" -type f -newer /tmp/start -not -newer /tmp/end -size +1G -exec mv "{}" "$2" \;
rm /tmp/start /tmp/end

相关内容