dmesg 中时间信息转换

#!/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'

 使用方法:

server231:/var/testing/client # ./test.sh 3310.560164
1583910130.010164
2020-03-11 15:02:10

猜你喜欢

转载自www.cnblogs.com/longchang/p/12462474.html