亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

Chinaunix

標(biāo)題: 這個程序老是提示有錯誤是怎么回事? [打印本頁]

作者: mosquitoh    時間: 2015-03-12 18:35
標(biāo)題: 這個程序老是提示有錯誤是怎么回事啊?
  1. read -p "please input your damozilition date: " date2

  2. date_check=$(echo $date2 | grep '[0-9]\{8\}')
  3. if [ "$date_check" == "" ]; then
  4.         echo "you input the wrong data format..."
  5.         exit 1
  6. fi

  7. #declare -i date_dem=`date --date="$date2" +%s`
  8. #declare -i date_now=`date --date="date" +%s`
  9. #declare -i date_total_s=$(($date_dem-$date_now))
  10. #declare -i date_d=$(($date_total_s/60/60/24))
  11. #declare -i date_hour=$(($(($date_total_s - $date_d*24*60*60))/60/60))
  12. #declare -i date_sec=$(($date_total_s - $date_d*24*60*60 - $date_hour*60))
  13. #
  14. #if [ "$date_total_s" lt "0" ]; then
  15. #       echo "You had been demolization " $date_d " days " $date_hour " hours " $date_sec "seconds"
  16. #else
  17. #       echo "You will demolization after " $date_d " days " $date_hour " hours " $date_sec " seconds"
  18. #fi
復(fù)制代碼
剛剛寫的,很多錯誤,我把后面的都注釋掉了,就是前面的那一小段代碼也有問題,求助!。
作者: mosquitoh    時間: 2015-03-12 18:38
sh11.sh: 4: [: 20091223: unexpected operator


作者: zsszss0000    時間: 2015-03-12 18:59
我運(yùn)行就沒有問題啊
作者: mosquitoh    時間: 2015-03-12 19:36
我的是ubutun 14.10,老是提示
sh11.sh: 4: [: 20091223: unexpected operator
怎么回事?
作者: zsszss0000    時間: 2015-03-12 19:43
本帖最后由 zsszss0000 于 2015-03-12 19:44 編輯

你在第四行之前價格打印
  1. echo $date_check
復(fù)制代碼
看看你獲取的date_check是什么?回復(fù) 4# mosquitoh


   
作者: mosquitoh    時間: 2015-03-12 19:57
原來要把第四行的“==”改為“=”
求解答????
作者: zsszss0000    時間: 2015-03-12 20:17
本帖最后由 zsszss0000 于 2015-03-12 20:19 編輯

http://72891.cn/thread-1048907-1-1.html
根據(jù)這篇帖子,shell中的=不是賦值而是字符串比較運(yùn)算符號回復(fù) 6# mosquitoh


   
作者: mosquitoh    時間: 2015-03-12 20:33
謝謝了,終于調(diào)試完成運(yùn)行成功,代碼如下,和鳥哥寫的做了一點修改,
  1. read -p "please input your damozilition date: " date2

  2. date_check=$(echo $date2 | grep '[0-9]\{8\}')
  3. if [ "$date_check" = "" ]; then
  4.         echo "you input the wrong data format..."
  5.         exit 1
  6. fi

  7. declare -i date_dem=$(date --date="$date2" +%s)
  8. declare -i date_now=`date +%s`
  9. declare -i date_total_s=$(($date_dem-$date_now))
  10. declare -i date_d=$(($date_total_s/60/60/24))
  11. declare -i date_hour=$(($(($date_total_s - $date_d*24*60*60))/60/60))
  12. declare -i date_min=$(($(($date_total_s - $date_d*24*60*60 - $date_hour*60*60))/60))

  13. if [ "$date_total_s" -lt "0" ]; then
  14.         echo "You had been demolization" $((-1*$date_d)) "days" $((-1*$date_hour)) "hours" $((-1*$date_min)) "minutes"
  15. else
  16.         echo "You will demolization after" $date_d "days" $date_hour "hours" $date_min "minutes"
  17. fi
復(fù)制代碼

作者: zsszss0000    時間: 2015-03-12 20:38
看來是這個版本的shell不支持==導(dǎo)致的問題




歡迎光臨 Chinaunix (http://72891.cn/) Powered by Discuz! X3.2