<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    The NoteBook of EricKong

      BlogJava :: 首頁 :: 聯(lián)系 :: 聚合  :: 管理
      611 Posts :: 1 Stories :: 190 Comments :: 0 Trackbacks

    1、date --help

    %% 輸出%符號(hào) a literal %
    %a 當(dāng)前域的星期縮寫 locale’s abbreviated weekday name (Sun..Sat)
    %A 當(dāng)前域的星期全寫 locale’s full weekday name, variable length (Sunday..Saturday)
    %b 當(dāng)前域的月份縮寫 locale’s abbreviated month name (Jan..Dec)
    %B 當(dāng)前域的月份全稱 locale’s full month name, variable length (January..December)
    %c 當(dāng)前域的默認(rèn)時(shí)間格式 locale’s date and time (Sat Nov 04 12:02:33 EST 1989)
    %C n百年 century (year divided by 100 and truncated to an integer) [00-99]
    %d 兩位的天 day of month (01..31)
    %D 短時(shí)間格式 date (mm/dd/yy)
    %e 短格式天 day of month, blank padded ( 1..31)
    %F 文件時(shí)間格式 same as %Y-%m-%d
    %g the 2-digit year corresponding to the %V week number
    %G the 4-digit year corresponding to the %V week number
    %h same as %b
    %H 24小時(shí)制的小時(shí) hour (00..23)
    %I 12小時(shí)制的小時(shí) hour (01..12)
    %j 一年中的第幾天 day of year (001..366)
    %k 短格式24小時(shí)制的小時(shí) hour ( 0..23)
    %l 短格式12小時(shí)制的小時(shí) hour ( 1..12)
    %m 雙位月份 month (01..12)
    %M 雙位分鐘 minute (00..59)
    %n 換行 a newline
    %N 十億分之一秒 nanoseconds (000000000..999999999)
    %p 大寫的當(dāng)前域的上下午指示 locale’s upper case AM or PM indicator (blank in many locales)
    %P 小寫的當(dāng)前域的上下午指示 locale’s lower case am or pm indicator (blank in many locales)
    %r 12小時(shí)制的時(shí)間表示(時(shí):分:秒,雙位) time, 12-hour (hh:mm:ss [AP]M)
    %R 24小時(shí)制的時(shí)間表示 (時(shí):分,雙位)time, 24-hour (hh:mm)
    %s 自基礎(chǔ)時(shí)間 1970-01-01 00:00:00 到當(dāng)前時(shí)刻的秒數(shù) seconds since `00:00:00 1970-01-01 UTC’ (a GNU extension)
    %S 雙位秒 second (00..60); the 60 is necessary to accommodate a leap second
    %t 橫向制表位(tab) a horizontal tab
    %T 24小時(shí)制時(shí)間表示 time, 24-hour (hh:mm:ss)
    %u 數(shù)字表示的星期(從星期一開始 1-7)day of week (1..7); 1 represents Monday
    %U 一年中的第幾周星期天為開始 week number of year with Sunday as first day of week (00..53)
    %V 一年中的第幾周星期一為開始 week number of year with Monday as first day of week (01..53)
    %w 一周中的第幾天 星期天為開始 0-6 day of week (0..6); 0 represents Sunday
    %W 一年中的第幾周星期一為開始 week number of year with Monday as first day of week (00..53)
    %x 本地日期格式 locale’s date representation (mm/dd/yy)
    %X 本地時(shí)間格式 locale’s time representation (%H:%M:%S)
    %y 兩位的年 last two digits of year (00..99)
    %Y 年 year (1970…)
    %z RFC-2822 標(biāo)準(zhǔn)時(shí)間格式表示的域 RFC-2822 style numeric timezone (-0500) (a nonstandard extension)
    %Z 時(shí)間域 time zone (e.g., EDT), or nothing if no time zone is determinable

    By default, date pads numeric fields with zeroes. GNU date recognizes
    the following modifiers between `%’ and a numeric directive.

    `-’ (hyphen) do not pad the field
    `_’ (underscore) pad the field with spaces

    --------------------------------------------------------------------------------

    2、一些用法

    1)#以yymmdd的格式輸出43天前的當(dāng)前時(shí)刻

    date +%Y%m%d --date='43 days ago'       

     

    2)# 測試十億分之一秒
    date +’%Y%m%d %H:%M:%S.%N’;date +’%Y%m%d %H:%M:%S.%N’;date +’%Y%m%d %H:%M:%S.%N’;date +’%Y%m%d %H:%M:%S.%N’

    3)#創(chuàng)建以當(dāng)前時(shí)間為文件名的目錄
    mkdir `date +%Y%m%d`

     

    4)#備份以時(shí)間做為文件名的
    tar -cvf ./htdocs`date +%Y%m%d`.tar ./*

     

    5)#顯示時(shí)間后跳行,再顯示目前日期 

    date +%T%n%Y%m%d

     

    6)#只顯示月份與日數(shù) 

    date +%B%d

     

    7)#獲取上周日期(day,month,year,hour)

    date -d "-1 week" +%Y%m%d   

     

    8)#獲取24小時(shí)前日期

    date --date="-24 hour" +%Y%m%d

     

    9)#shell腳本里面賦給變量值

    date_now=`date +%s`

     

    10)#計(jì)算執(zhí)行一段sql腳本的運(yùn)行時(shí)間

     

    TIME_BEGIN=$(date '+%s.%N')
    $sqlcli < queries/q1.3.sql 1>> $FILE_RESULT  2>> $FILE_ERROR
    TIME_END=$(date '+%s.%N')
    TIME_RUN=$(awk 'BEGIN{print '$TIME_END' - '$TIME_BEGIN'}')

     

    11)#編寫shell腳本計(jì)算離自己生日還有多少天?

        read -p "Input your birthday(YYYYmmdd):" date1

      m=`date --date="$date1" +%m`    #得到生日的月

      d=`date --date="$date1" +%d`    #得到生日的日

      date_now=`date +%s`             #得到當(dāng)前時(shí)間的秒值

      y=`date +%Y`                    #得到當(dāng)前時(shí)間的年

      birth=`date --date="$y$m$d" +%s`      #得到今年的生日日期的秒值

      internal=$(($birth-$date_now))        #計(jì)算今日到生日日期的間隔時(shí)間

      if [ "$internal" -lt "0" ]; then             #判斷今天的生日是否已過

      birth=`date --date="$(($y+1))$m$d" +%s`      #得到明天的生日日期秒值

      internal=$(($birth-$date_now))               #計(jì)算今天到下一個(gè)生日的間隔時(shí)間

      fi

      echo "There is :$((einternal/60/60/24)) days."       #輸出結(jié)果,秒換算為天

     

     

    12)#若是不以加號(hào)作為開頭,則表示要設(shè)定時(shí)間,而時(shí)間格式為 MMDDhhmm[[CC]YY][.ss],

    其中 MM 為月份,

    DD 為日,

    hh 為小時(shí),

    mm 為分鐘,

    CC 為年份前兩位數(shù)字,

    YY 為年份后兩位數(shù)字,

    ss 為秒數(shù)

     

    13)

    #顯示目前的格林威治時(shí)間,也叫“世界時(shí)”。是英國的標(biāo)準(zhǔn)時(shí)間,也是世界各地時(shí)間的參考標(biāo)準(zhǔn)。中英兩國的標(biāo)準(zhǔn)時(shí)差為8個(gè)小時(shí),即英國的當(dāng)?shù)貢r(shí)間比中國的北京時(shí)間晚8小時(shí)。

    date -u              
    Thu Sep 28 09:32:04 UTC 2006

     

    14)#修改時(shí)間

    date -s
    按字符串方式修改時(shí)間
    可以只修改日期,不修改時(shí)間,輸入: date -s 2007-08-03
    只修改時(shí)間,輸入:date -s 14:15:00
    同時(shí)修改日期時(shí)間,注意要加雙引號(hào),日期與時(shí)間之間有一空格,輸入:date -s "2007-08-03 14:15:00"

    修改完后,記得輸入:clock -w
    把系統(tǒng)時(shí)間寫入CMOS

    posted on 2015-07-23 15:50 Eric_jiang 閱讀(435) 評(píng)論(0)  編輯  收藏 所屬分類: Linux
    主站蜘蛛池模板: 亚洲va久久久噜噜噜久久男同| 免费人成视频在线| 337p日本欧洲亚洲大胆裸体艺术| 成人亚洲国产va天堂| 国产曰批免费视频播放免费s| 亚洲电影中文字幕| 久久国产精品2020免费m3u8| 亚洲成色WWW久久网站| 美女视频黄a视频全免费网站色窝 美女被cao网站免费看在线看 | 免费成人福利视频| 456亚洲人成在线播放网站| 国产免费毛不卡片| 亚洲AV无码XXX麻豆艾秋| 国产又黄又爽又猛的免费视频播放 | 97在线视频免费播放| 亚洲成人网在线观看| 野花高清在线电影观看免费视频| 亚洲综合一区国产精品| 国产成人免费a在线资源| 青娱乐在线免费观看视频| 国产精品亚洲精品日韩已方| 国产自国产自愉自愉免费24区| 亚洲视频一区调教| 亚洲免费综合色在线视频| 亚洲另类自拍丝袜第五页| 亚洲不卡AV影片在线播放| 日本高清不卡aⅴ免费网站| 亚洲人成电影福利在线播放| 一区二区无码免费视频网站| 精品久久亚洲一级α| 亚洲成AV人片一区二区| 1000部拍拍拍18勿入免费凤凰福利| 亚洲人成电影网站免费| 中文字幕亚洲一区| 免费电影在线观看网站| 免费国产污网站在线观看不要卡 | 国产福利在线免费| 一级特黄录像免费播放中文版| 亚洲久本草在线中文字幕| 四虎在线免费播放| 精品一区二区三区免费|