- 论坛徽章:
- 0
|
请自行建立一支程序,该程序可以用来计算『你还有几天可以过生日』啊?
#!/bin/bash read -p "Pleas input your birthday (MMDD, ex> 0709): " bir now=`date +%m%d` if [ "$bir" == "$now" ]; then echo "Happy Birthday to you!!!" elif [ "$bir" -gt "$now" ]; then year=`date +%Y` total_d=$(($((`date --date="$year$bir" +%s`-`date +%s`))/60/60/24)) echo "Your birthday will be $total_d later" else year=$((`date +%Y`+1)) total_d=$(($((`date --date="$year$bir" +%s`-`date +%s`))/60/60/24)) echo "Your birthday will be $total_d later" fi
这是pdf的代码 |
|