Copy codeThe Code is as follows :#! /Bin/sh
# Obtain the date interval from the first day of the quarter to yesterday
# Link: www.jb51.net
# Date: 2013/2/28
Day = 'date-d "1 days ago" "+ % Y % m % d "';
Year = 'expr substr $ {day} 1 4 ';
Month = 'expr substr $ {day} 5 2 ';
S_date = $ year "0101"
If ["$ month" = "01"] | ["$ month" = "02"] | ["$ month" = "03"]; then
S_date = $ year "0101"
Elif ["$ month" = "04"] | ["$ month" = "05"] | ["$ month" = "06"]; then
S_date = $ year "0401"
Elif ["$ month" = "07"] | ["$ month" = "08"] | ["$ month" = "09"]; then
S_date = $ year "0701"
Elif ["$ month" = "10"] | ["$ month" = "11"] | ["$ month" = "12"]; then
S_date = $ year "1001"
Fi
E_date = $ day
Sys_s_data = 'date-d "$ s_date" + % s'
Sys_e_data = 'date-d "$ e_date" + % s'
Interval = 'expr $ sys_e_data-$ sys_s_data'
Daycount = 'expr $ interval/3600/24 + 1'
Echo $ daycount