歡迎您光臨本站 註冊首頁

這段shell我照著書上打得,不知道哪裡出錯了,,

←手機掃碼閱讀     火星人 @ 2014-03-24 , reply:0

#!/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 能幫我看下嘛???

[火星人 ] 這段shell我照著書上打得,不知道哪裡出錯了,,已經有191次圍觀

http://coctec.com/docs/linux/show-post-143713.html