Time period parameter passed by Shell

Source: Internet
Author: User

#! /Bin/sh
D1 = 20111201.
D2. = 20120625
Time = $ (date + % s-d ''$ D2'')-$ (date + % s-d ''$ D1 ''))); # date difference
T = 'expr $ time/100' # Number of different days
For (I = 0; I <= $ t; I = I + 1 ))
Do
# Echo $ d1
Perl XX. pl $ d1
D1 = 'date-d' $ D1 'utc 86400 seconds' + "% Y % m % d "'

Done


Note:

D1 = 'date-d' $ D1 'utc 86400 seconds' + "% Y % m % d "'

In the format of "% Y % m % d", the date of 86400 seconds after '$ D1' UTC is displayed, that is, the date of the day after D1.


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Lili split line ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~

Another method:

Startday = "20120901"
Datestr = ""
For I in 'seq 0 39 '# Time period from20120901-20121010"
Do
Datestat = 'date-d "$ startday + $ I day" "+ % Y % m % d "'
Datestr + = "/XXX/" $ {datestat }"/?? /Xxx. log. "$ {datestat }"?? "
Done
Echo "$ datestr"
Period = "20120901-20121010"
Perl baikelogstat. pl $ period $ datestr



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.