#!/bin/bash
#program:
#check how long you will demobilization form the army
#histoyr:
#2010/8/21
#!/bin/sh
echo "this program will try to calculate"
echo "how many days beforre your demobilization date ............."
read -p "plseae input your demobilization date (YYYYYMMDD ex>20090401):" date2
date_d=$( echo $date2 | grep '[0-9]\{8\}')
if [ "$date_d" == "" ]; then
echo "you input the wrong date format"
exit 1
fi
declare -i date_dem=`date --date="$date2" +%s`
declare -i date_now=`date +%s`
declare -i date_total_s= $(($date_dem-$date_now))
declare -i date_d = $(($date_total_s/60/60/24))
if [ "$date_total_s" -lt "0" ]; then
echo "you had been demobilization before: "((-1*$date_d))" ago"
else
declare -i date_h= $(( $(( $date_total_s - $date_d*60*60*24))/60/60))
echo "you will demobilize after $date_d days and $date_h hours"
fi
//报错是如图[localimg=180,79]1[/localimg]
代码是[localimg=180,91]3[/localimg]
今天是20100821 ,我输的是20100822 能帮我看下嘛???
crossbitter 于 2011-09-16 21:29:05发表:
空格。。我前几天配置服务器丢了个.
心成一线 于 2011-09-15 20:06:25发表:
shell cripts可以进行debug啊
用“sh +x 文件名”这个语句,看出这个可执行文件 每一步的执行过程。
405492 于 2010-08-25 09:50:35发表:
学习了,空格的确很不起眼
f78815925 于 2010-08-23 10:16:20发表:
学习中!
wst021 于 2010-08-23 10:12:53发表:
出?才能遇到??,解?了??就增???,?也?好得!
pallana 于 2010-08-23 10:03:34发表:
空格?学习了
yanlong938 于 2010-08-22 23:02:13发表:
空格 总是惹很多麻烦 哎
yezhubenyue 于 2010-08-22 17:34:35发表:
晕,,,,,好感谢!!!!!!!!!!!!!!!
yimingtao 于 2010-08-22 10:49:50发表:
declare -i date_total_s= $(($date_dem-$date_now))
=与$之间不应有空格
yezhubenyue 于 2010-08-22 09:58:12发表:
谢谢了~~~~~~~~~~~~~~~~~~
yezhubenyue 于 2010-08-22 09:57:59发表:
[attach]31870[/attach]
yezhubenyue 于 2010-08-22 09:56:34发表:
[attach]31869[/attach]