vim /tmp/get_sysytem_timestamp.sh
#!/bin/bash
if [ -z $1 ];then #判断是否没输入参数
echo '请输入参数!'
elif [ $1 -gt 0 ] 2> /dev/null;then
date -d "1970-01-01 UTC $1 seconds" +"%Y-%m-%d %T"
else
echo '请输入正常参数!'
fi
执行脚本
[root@An ~]# sh get_sysytem_timestamp.sh 91641809
1972-11-27 00:03:29
python写法:
time.strftime("%Y-%m-%d %H:%M:%S",time.localtime(91641809))