bash比较文件时间和当前时间

 

ft=`date +%Y%m%d%H%M%S -Iseconds -r filea`
ct
=`date +%Y%m%d%H%M%S -Iseconds`
if [ "$ct" -gt "$ft" ]
then
  echo 
"Current Time Large than file time"
  echo 
"$ct - $ft = "
  echo $[
$ct-$ft]
fi 

上面的秒数计算是不对的。

echo $[`date +%H` * 3600 + `date +%M` * 60 + `date +%S`]
这样算出来的就是准确的秒啦.

posted on 2006-09-25 22:14  CrazyWill  阅读(2187)  评论(0编辑  收藏  举报

导航