我需要获取所有大于时间戳的文件,并带有前缀条件。例如,所有包含myfile*.zip > 2019-11-11 13:00:00,000的文件,因此如果我收到以下内容:
myfile1.zip - 2019-11-10 13:00:00,000
myfile2.zip - 2019-11-11 10:00:00,000
myfile3.zip - 2019-11-11 13:00:00,000
myfile4.zip - 2019-11-11 17:00:00,000我想要下一个结果:
myfile3.zip - 2019-11-11 13:00:00,000
myfile4.zip - 2019-11-11 17:00:00,000我需要使用Python或Airflow S3KeySensor来做到这一点。
发布于 2019-10-11 21:12:33
Bash解决方案:
您可以组合使用touch -t和find -newer。touch将创建具有特定修改日期的文件,并且find -newer将仅列出比创建的文件更新的文件。例如:
# for 2019-11-11 13:00:00,000
# Edit: This is currently in the future, so no results for you!
touch -t 201911111300 mytempfile.temp
find . -name 'myfile*.zip' -newer mytempfile.temp
rm mytempfile.temp来自touch --help
-t STAMP use [[CC]YY]MMDDhhmm[.ss] instead of current time
--time=WORD change the specified time:
WORD is access, atime, or use: equivalent to -a
WORD is modify or mtime: equivalent to -mhttps://stackoverflow.com/questions/58341617
复制相似问题