begintime=`date +%s`
sleep 2s
endtime=`date +%s`
duration=$(($endtime-$begintime))
echo $endtime
echo $duration in seconds
echo $(($duration/3600)) in hours
sleep 2s
endtime=`date +%s`
duration=$(($endtime-$begintime))
current=`date +%Y/%m/%d-%H:%M:%S`
echo $current
echo $begintime
echo $endtime
echo $duration in seconds
echo $(($duration/3600)) in hours
echo $(($duration/86400)) in days
创建以日期命名的目录
mkdir `date +%Y%m%d`.dir
本文介绍了一种利用bash脚本进行时间戳获取、计算持续时间及创建按日期命名目录的方法。通过简单的命令组合实现时间戳的记录与计算,并演示了如何通过bash脚本来创建以当前日期为名的目录。
503

被折叠的 条评论
为什么被折叠?



