用shell scripts 脚本完成 计算"您还有几天就过生日"
来源:互联网 发布:域名和空间怎么绑定 编辑:程序博客网 时间:2024/05/21 08:04
先在此说明,我是个新手,自学的Linux shell编程.
以下是我的一点见解,觉得很不完善,希望高手们能够给予指导.
觉得应该可以用很简洁的办法解决这个问题.
#!/bin/bash
# Using brithday .......
#liyy 2010/12/30
declare date=`date`
echo "nowdate is $date"
echo `date|cut -c7-13`
now=`date|cut -c7-13`
nowmonth=`date|cut -c7-8`
echo "nowmonth==>$nowmonth"
nowday=`date|cut -c11-12`
echo "nowday==>$nowday"
declare -i birthmonth
declare -i birthday
echo "please input your birthmonth."
read birthmonth
echo "please input your birthday."
read birthday
declare -i ddmonth=`expr $birthmonth - $nowmonth`
declare -i ddday=`expr $birthday - $nowday`
echo "ddmonth==>$ddmonth"
echo "ddday==>$ddday"
if [ "$ddmonth" -eq "0" ]; then
if [ "$ddday" -gt "0" ]; then
echo "after $ddday day ,you will birthday"
fi
elif [ "$ddmonth" -gt "0" ] && [ "$ddday" -gt "0" ]; then
echo "after $ddmonth month + $ddday day will your birthday"
elif [ "$ddmonth" -gt "0" ] && [ "$ddday" -lt "0" ]; then
echo "after `expr $ddmonth - 1` month+`expr 30 - $nowday + $birthday` day will your birthday"
else
echo "this year your birthday is over ."
fi
- 用shell scripts 脚本完成 计算"您还有几天就过生日"
- 还有几天就回家了,期待中……
- 【Java】Java根据出生日期计算还有几天的生日
- shell脚本删除几天前的备份文件
- shell脚本完成冒泡排序
- shell scripts
- shell scripts
- Shell Scripts
- shell scripts
- 一天一linux命令(17) shell scripts 脚本
- shell scripts登录远程主机执行远程脚本
- shell脚本之数值计算
- 计算shell脚本的执行时间
- shell脚本完成hadoop的集群安装
- shell Bash脚本指定日期的前/后几天
- 用shell脚本,指定两个日期,计算相隔天数
- 用shell脚本计算日期的小函数们
- 过生日
- linux 命令
- [QT][源码分析]QObject::connect
- 一个软件行业中层主管在年底给团队成员的一封信
- 界面构造UI界面
- 电荷泵原理
- 用shell scripts 脚本完成 计算"您还有几天就过生日"
- JDBC事务的控制问题
- 2010 现在完成进行时...
- PuTTY Download Page - PuTTY 工具下载页
- JS去掉空格回车换行(转http://hi.baidu.com/niubore/blog/item/27c77b89ca1dead8fd1f102a.html)
- 我们都是好孩子!
- 设置一个JTable中某些单元格的背景色
- Wince的调试串口修改
- JS判断输入是否为整数的正则表达式