我已經編寫了一個腳本來遍歷Solaris中的目錄。該腳本查找超過30分鐘並回顯的文件。但是,無論文件有多大,我的if條件總是返回true。有人請幫助解決這個問題。如何檢查unix中的文件是否超過30分鐘
for f in `ls -1`;
# Take action on each file. $f store current file name
do
if [ -f "$f" ]; then
#Checks if the file is a file not a directory
if test 'find "$f" -mmin +30'
# Check if the file is older than 30 minutes after modifications
then
echo $f is older than 30 mins
fi
fi
done
'if test'find「$ f」-mmin + 30'' should be'[$(fi nd「$ f」-mmin +30)]' – fedorqui