Perl 如何查找上次修改的文件及其';时间戳不迟于今天?
我有一个名为Perl 如何查找上次修改的文件及其';时间戳不迟于今天?,perl,file,bash,awk,ls,Perl,File,Bash,Awk,Ls,我有一个名为filename.${date}的文件列表,例如foo.20121102,我想使用bash工具集打印到今天为止具有时间戳的最后修改的文件 # 24 hours * 60 minutes/hour * 60 seconds/minute $threshhold = 86400; $currenttime = time(); if( ($currenttime - $mtime) > $threshhold){ # file was modified within 24 h
filename.${date}
的文件列表,例如foo.20121102
,我想使用bash工具集打印到今天为止具有时间戳的最后修改的文件
# 24 hours * 60 minutes/hour * 60 seconds/minute
$threshhold = 86400;
$currenttime = time();
if( ($currenttime - $mtime) > $threshhold){
# file was modified within 24 hours
}
对于昨晚午夜后修改的文件:
if( $mtime > ($currenttime - ($currenttime % 86400)){
# file was modified this calendar day
}
更多信息使用
shell
如您所问:
for i in *; do
if stat -c %y "$i" | grep -q "^$(date +%Y-%m-%d)"; then
echo "$i has been modified or created today"
else
echo "$i has NOT been modified or created today"
fi
done
您需要上午00:00之前的文件吗?还是过去24小时的文件?