2013-10-05 28 views
0

我知道我可以在Linux系統中使用date +%sstat如何創建比較文件的shell腳本文件修改時間和Solaris上的當前時間

但是,由於Solaris不支持那些格式或命令的紀元, 如何創建一個shell腳本來比較文件修改時間和當前時間?

與當前時間相比,修改文件時間應該在10分鐘之內。

[ShellScript] 

Current_Time= 
Modification_Time= 

Compare = Current_Time - Modification_time 

if ["$Compare" -gt 600]; then 
Echo "there is no find found within 10 min" 
else 
Echo "Found the file" 
if 
+0

了'date' cmd在'/ usr/xpg4/bin'具有額外的功能,可以讓你的任務變得更容易,但是我6年來沒有訪問過Solaris,所以我可能會誤會。祝你好運。 – shellter

回答

0

要知道,如果somefile在最後十分鐘修改,就可以運行這個命令:

file=somefile 
if [ -n $(find . -name $file -mmin +10 2>/dev/null) ]; then 
    echo " $file was just modified" 
else 
    echo " $file stayed unchanged" 
fi 
+0

謝謝jilliagre,腳本工作正常:) –

0

查找命令應該可以解決你的問題,你試了一下嗎?

$ find . -mmin 10 -print 

-mmin n(以分鐘修改時間)

相關問題