#!/bin/bash
##############################
_Green="\033[32;1m"
_Red="\033[31;1m"
_End="\033[0m"
##############################
Server_Lang="`echo "${LANG}"`"
Search_Time="`date +%Y%m%d%H%M%S`"
##############################
echo -e "${_Green}The System Default Language: ${Server_Lang} ${_End}"
while ((1==1))
do
read -p "Enter the year you want to query ! :" Query_Year
if [[ "${Query_Year}" =~ ^[1-9][0-9]{0,3}$ ]]
then
for i in `seq -w 1 1 12`
do
Query_Re_Mon="`/usr/bin/cal -m ${i} ${Query_Year} | /usr/bin/sed -n '3,${/^$/d;p}' | /usr/bin/awk -F' ' '$0 !~ /^ /{printf "'${Query_Year}'-'${i}'-%02d\n",$1}'`"
echo "${Query_Re_Mon}" >> /tmp/.SM${Search_Time}
Query_Re_Sun="`/usr/bin/cal -s ${i} ${Query_Year} | /usr/bin/sed -n '3,${/^$/d;p}' | /usr/bin/awk -F' ' '$0 !~ /^ /{printf "'${Query_Year}'-'${i}'-%02d\n",$1}'`"
echo "${Query_Re_Sun}" >> /tmp/.SS${Search_Time}
done
/usr/bin/paste /tmp/.SM${Search_Time} /tmp/.SS${Search_Time} >> /tmp/.QS${Search_Time}.xls
/usr/bin/awk 'BEGIN{printf "%10s\t%10s\n","Monday","Sunday"}{printf "%10s\t%10s\n",$1,$2}' /tmp/.QS${Search_Time}.xls >> /tmp/QS${Search_Time}.xls
if [ -s "/tmp/QS${Search_Time}.xls" ]
then
echo -e "${_Green}File saved in:/tmp/QS${Search_Time}.xls ${_End}"
else
echo -e "${_Red}File saved False ${_End}"
fi
exit
else
echo -e "${_Red} Input erro ${_End}"
continue
fi
done
转载于:https://blog.51cto.com/chlipeng/1742424