vim /tmp/get_sysytem_timestamp.sh
#!/bin/bash
if [ -z $1 ];then? #判斷是否沒輸入?yún)?shù)
echo '請輸入?yún)?shù)!'
elif [ $1 -gt 0 ] 2> /dev/null;then
date -d "1970-01-01 UTC $1 seconds" +"%Y-%m-%d %T"
else
echo '請輸入正常參數(shù)!'
fi
執(zhí)行腳本
[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))