Bash Shell脚本:输入时间,输出距离你的生日天数
来源:互联网 发布:淘宝违规宝贝怎么删除 编辑:程序博客网 时间:2024/05/17 03:55
#!/bin/bash#Program:# Input your birthday date and the program will calculate how many days before you birthday comes#History: # 2016/03/27 Linyimin First releasePATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/binexport PATHread -p "Input your birthday date(YYYYMMDD,ex -->20160327)" date1if [ "$(echo $date1 | grep "[0-9]\{8\}")" == "" ];then echo "Input error!" exit 0fi #计算今天距1970年的时间秒数declare -i date_today=$(date +%s --date=$(date +%Y%m%d))declare -i date_input=$(date +%s --date=$date1)declare -i date_diff=$(($date_input-$date_today))if [ $date_diff -lt 0 ];then date_diff=$(($date_today-$date_input)) declare -i days=$(($date_diff/60/60/24)) echo "Your birthday have passed $days days!" exit 0 fi days=$(($date_diff/60/60/24))echo "There are also $days days when your birthday comes!"exit 0
0 0
- Bash Shell脚本:输入时间,输出距离你的生日天数
- BASH命令和SHELL脚本总结(17)在BASH中计算两天的间隔天数
- 计算距离你的生日还有多久
- unix 的 bash shell 脚本
- 获取距离当前时间任意天数的时间
- shell的输入、输出
- shell的输入,输出
- 计算自己生日距离现在多长时间的脚本程序
- BASH命令和SHELL脚本总结(11)比较两个文件创建时间的先后
- 脚本、shell、shell脚本、bash的个人理解
- bash脚本,自动输入sudo的密码
- bash脚本,自动输入sudo的密码
- bash脚本,自动输入sudo的密码
- 编写健壮的Bash shell脚本
- 调用bash shell脚本的方式
- bash,shell脚本中的fi的解读
- 编写健壮的Bash shell脚本
- 编写健壮的Bash shell脚本
- DuiLib(4)——消息响应
- 带权重的随机算法
- JavaScript版HashMap的简单实现——通过原型prototype扩展
- [BZOJ1977][BeiJing2010组队]次小生成树 Tree(kruskal+链剖)
- poj1961 kmp失效函数的运用
- Bash Shell脚本:输入时间,输出距离你的生日天数
- josn数据解析,建立定时服务(天气预报demo)
- Javascript中数组的常用方法。
- Java多线程之synchronized及死锁编写
- 各种排序算法
- Contacts Provider
- OpenCV1.0在VC ++6.0下的配置
- 嵌入式Linux下MP4视频录制库MP4V2移植和简介
- 继承的定义和具体使用-1