shell时间戳与时间相互转换
#!/bin/bash
read -p "时间转化为时间戳请输入1,时间戳转化为时间请输入2:" time0
if [ $time0 -eq 1 ];then
read -p "请输入你要转化的时间戳:" time1
date -d @"$time1" "+%F %T" 2> /dev/null
fi
if [ $time0 -eq 2 ];then
read -p "请输入你要转化的时间(xxxx-xx-xx xx:xx:xx):" time2
date -d "$time2" +%s 2> /dev/null
fi
exit
if [ $time0 -eq 2 ];then
echo "输入错误!!!"
exit
fi
--by Frank_hui
转载请标明原博客地址链接