【发布时间】:2014-05-11 22:14:43
【问题描述】:
我编写了一个脚本来遍历 Solaris 中的一个目录。该脚本查找超过 30 分钟的文件并回显。但是,无论文件有多旧,我的 if 条件总是返回 true。请有人帮忙解决这个问题。
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'应该是[ $(find "$f" -mmin +30) ]
标签: shell unix sh unix-timestamp solaris-10