shell (2) 时间处理

获取当前的时间,并输出

#!/bin/bash
if [ $# -ne 1 ];then
    echo "input an dmesg time"
    exit 1
fi
unix_time=`echo "$(date +%s) - $(cat /proc/uptime | cut -f 1 -d' ') + ${1}" | bc`
echo ${unix_time}
date -d "@${unix_time}" '+%Y-%m-%d %H:%M:%S'
posted @ 2018-11-28 17:17  linengier  阅读(171)  评论(0编辑  收藏  举报