0
比較兩個文件的執行時間,我必須使用Perl或shell腳本的兩個文件的最後執行的時間比較知道的執行時間,並使用Perl或shell腳本
file1.txt 22:07 20-12-13
file2.txt 22:30 21-12-14
想要比較哪一個執行最新
請幫助提前
比較兩個文件的執行時間,我必須使用Perl或shell腳本的兩個文件的最後執行的時間比較知道的執行時間,並使用Perl或shell腳本
file1.txt 22:07 20-12-13
file2.txt 22:30 21-12-14
想要比較哪一個執行最新
請幫助提前
perl -le '@[email protected]; print $r[-M $r[0] > -M $r[1]]' file1.txt file2.txt
感謝究竟你「上次執行時間」是什麼意思?我的回答工作與上次修改時間:
在外殼,可以使用-nt
和-ot
測試:
if [ "$file1" -nt "$file2" ] ; then
echo "$file1 is newer than $file2."
fi
在Perl,使用-M
文件測試:
if (-M $file1 < -M $file2) {
print "$file1 is newer than $file2.\n";
}
可以請你幫忙,開關-E和-M不工作從我 – user3044691
謝謝,它的解決fr我 – user3044691