发布于 2017-03-21 23:35:11 | 83 次阅读 | 评论: 0 | 来源: PHPERZ

这里有新鲜出炉的Shell教程,程序狗速度看过来!

Shell 命令解析器

在计算机科学中,Shell俗称壳(用来区别于核),是指“提供使用者使用界面”的软件(命令解析器)。它类似于DOS下的command和后来的cmd.exe。它接收用户命令,然后调用相应的应用程序。


vim timeforyou.sh

#/bin/bash
##by cc

read -p "Please input yourtime:" time
a=$time
if [ $a != 0 ]
then
date -s "$a" 1>>/dev/null
##获取你的时间戳
time1=`date +%s`
ntpdate time.nist.gov 1>>/dev/null
##获取当前时间戳
time2=`date +%s`
##秒
result_second=$[$time2-$time1]
##分
time3=$[$time2-$time1]
result_min=$[$time3/60]
##时
result_hour=$[$result_min/60]
##日
result_day=$[$result_hour/24]
##周
result_week=$[$result_day/7]
##月
result_moth=$[$result_week/4]

echo "距离当前时间:"
echo "秒" $result_second
echo "分" $result_min
echo "时" $result_hour
echo "日" $result_day
echo "周" $result_week
echo "月" $result_moth
fi



最新网友评论  共有(0)条评论 发布评论 返回顶部

Copyright © 2007-2017 PHPERZ.COM All Rights Reserved   冀ICP备14009818号  版权声明  广告服务