¿ìËÙÒµÎñͨµÀ

Linuxѧϰ֮ѧϰshell½Å±¾Ðøд2

×÷Õß ØýÃû¼¼Êõ À´Ô´ Linuxϵͳ ä¯ÀÀ ·¢²¼Ê±¼ä 2012-04-01

Õâ½ñÌìÒ»Ö±ÔÚæ,Ò²¾Íûʱ¼äд²©¿ÍÁË,ÏÂÎçÒª¸Ï»Ø¹ãÖÝ,Ã÷ÌìÈ¥ÃæÊÔ,Ï£ÍûÕâ¼Ò¹«Ë¾Äܸøµ½ÎÒÂúÒâµÄ´ýÓö.

ÔÚѧУ¹¤×÷ÁËÒ»Äê¶à,¼ûÖ¤Á˺ܶàÒõ°µµÄÒ»Ãæ,Ҳѧ²»µ½Ê²Ã´¶«Î÷ÁË,ÀÏÒ»±²µÄÈË,¶ÔÓÚѧУ,×ÜÊÇÓÐÒ»ÖÖĪÃûµÄÒÀÀµ¸ÐÔÚÄÇÀï,ÈÏΪ,Ö»ÒªÊÇѧУµÄ,¹¤×÷¶¼Îȶ¨,ȷʵ,ÔÚѧУ¹¤×÷,µÄÈ·Îȶ¨,µ«ÊÇ,¶ÔÓÚ¸öÈËÖ°ÒµµÄÉúÑÄ,ȴûÓÐʲô°ïÖú,ÎÒÌìÉúÊǸö²»°²·ÖµÄÈË,,¼´Ê¹¸¸Ä¸·´¶Ô¶¼ºÃ,ÎÒ¶¼»áÌø×ß,Ö»ÊÇʲôʱºòÌø¶øÒÑ,ÎÒÄ¿Ç°µÄн×ÊÊÇÈýǧ¶à,ÔÚÕâ¸öн×Ê,¶ÔÓÚ¹ãÖÝÀ´Ëµ,Æäʵ,ÊǺÜÉÙµÄÁË,×îÆðÂë,ÄãÔÚ¹ãÖÝÕâÀï,Ëæ±ãÏû·ÑÒ»ÏÂ,¾ÍÒѾ­¼¸°Ù²»¼ûÁË,Ï£ÍûÎÒµÄÏÂÒ»·Ý¹¤×÷,¿ÉÒÔ´ïµ½ËÄǧ¶à,ÎÒ²»ÊǸö¼±ÓÚ½ø¹¥µÄÈË,ÎÒϲ»¶ÂýÂýµÄÈÃ×Ô¼ºÅÀÉý,ÕâÑù»á¸øÎÒÒ»ÖÖ°²ÎȸÐ.

ºÃÁË,¸Õ²ÅдµÄÄÇЩ»°,ÎÞ·ÇÊÇÏë¹ÄÀø¹ÄÀø¡¢ÃãÀø×ÔÎÒ¶øÒÑ,ÏÖÔÚ½øÈëÎҵıʼÇÌìÌÃÁË.

ÔÚÉϼ¸ÆªÖÐ,¿ªÊ¼Á˽ű¾µÄ±àд,ÀÏʵ˵,ÎÒ²¢Ã»ÓÐѧ¹ý½Å±¾,¿´Äñ¸çµÄÊéµÄʱºò,¸Ð¾õÓеãÍ´¿à,ºÜ´ó¸ÅÄî²»ÊǺÜÇå³þ,»¹ºÃƾ½è×Å֮ǰѧ¹ý±à³ÌµÄ»ù´¡,²î²»¶àµÄÔ­Àí,²ÅÈÃ×Ô¼ºÂýÂýµÄ×ÁÄ¥Ã÷°×,¸Õ²Å,ÔÚÊÔÑéµÄ¹ý³ÌÖÐ,¶Ô×ÅÒ»¸ö½Å±¾,ÏëÁ˺ܾÃ,²Å¸ãÃ÷°×ÊÇÔõôһ»ØÊÂ,ÏÖÔÚ,¾Í°ÑÕâ¸ö½Å±¾ÌùÉÏÈ¥

#!/bin/bash
#Program:
# Tring to caluate your demobilization date at how many days later...
#History:
# 2010/11/25 Jackicy First release
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH

#1
¡¢¸æËßÓû§³ÌÐòµÄÓÃ;,²¢ÇÒ˵Ã÷Ó¦¸ÃÈçºÎÊäÈëÈÕÆÚ¸ñʽ
echo "This program will try to calculate :"
echo "How many days about your demobiliation date..."
read -p "Please input your demobilization date (YYYYMMDD ex>20101125):" date2

#2¡¢ÀûÓÃÕýÔò±í´ïʽ²âÊÔÒ»ÏÂ,Õâ¸öÊäÈëµÄÄÚÈÝÊÇ·ñÕýÈ·
date_d=`echo $date2 |grep ''[0-9]{8}''` //ÕâÀïÖÐ,ÎÒÒ»¿ªÊ¼ÊDz»Ã÷°×"{8}"Õâ¸öº¬ÒåµÄ,ºóÀ´Ã÷°×,Ô­À´ÊÇ´Ó0-9Õâ¸öÊý¾ÝÖÐ,Á¬ÐøÖظ´8¸öÇ°Ò»¸ö×Ö·û
if [ "$date_d" == "" ]; then
echo "You input the wrong format of date..."
exit 1
fi

#3
¡¢¿ªÊ¼¼ÆËãÈÕÆÚ
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 be demobilized after $date_d days and $date_h hours."
fi

±¾Îijö×Ô ¡°ÀÁèºáÐС± ²©¿Í,ÇëÎñ±Ø±£Áô´Ë³ö´¦http://jackicy.blog.51cto.com/422269/432030

ÁèÖڿƼ¼×¨ÒµÌṩ·þÎñÆ÷×âÓᢷþÎñÆ÷Íйܡ¢ÆóÒµÓʾ֡¢ÐéÄâÖ÷»úµÈ·þÎñ£¬¹«Ë¾ÍøÕ¾£ºhttp://www.lingzhong.cn ΪÁ˸ø¹ã´ó¿Í»§Á˽â¸ü¶àµÄ¼¼ÊõÐÅÏ¢£¬±¾¼¼ÊõÎÄÕÂÊÕ¼¯À´Ô´ÓÚÍøÂç,ÁèÖڿƼ¼×ðÖØÎÄÕÂ×÷ÕߵİæȨ£¬Èç¹ûÓÐÉæ¼°ÄãµÄ°æȨÓбØҪɾ³ýÄãµÄÎÄÕ£¬ÇëºÍÎÒÃÇÁªÏµ¡£ÒÔÉÏÐÅÏ¢ÓëÎÄÕÂÕýÎÄÊDz»¿É·Ö¸îµÄÒ»²¿·Ö,Èç¹ûÄúҪתÔر¾ÎÄÕÂ,Çë±£ÁôÒÔÉÏÐÅÏ¢£¬Ð»Ð»!

·ÖÏíµ½£º ¸ü¶à

Copyright ©1999-2011 ÏÃÃÅÁèÖڿƼ¼ÓÐÏÞ¹«Ë¾ ÏÃÃÅÓÅͨ»¥Áª¿Æ¼¼¿ª·¢ÓÐÏÞ¹«Ë¾ All rights reserved

µØÖ·(ADD)£ºÏÃÃÅÈí¼þÔ°¶þÆÚÍûº£Â·63ºÅ701E£¨¶«ÄÏÈÚͨÅÔ£© Óʱà(ZIP)£º361008

µç»°£º0592-5908028 ´«Õ棺0592-5908039 ×ÉѯÐÅÏ䣺web@lingzhong.cn ×ÉѯOICQ£º173723134

¡¶ÖлªÈËÃñ¹²ºÍ¹úÔöÖµµçÐÅÒµÎñ¾­ÓªÐí¿ÉÖ¤¡·ÃöB2-20100024  ICP±¸°¸:ÃöICP±¸05037997ºÅ