Linux下生提取一年中的周一和周日
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Linux下生提取一年中的周一和周日相关的知识,希望对你有一定的参考价值。
#!/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
本文出自 “工作经验” 博客,请务必保留此出处http://chlipeng.blog.51cto.com/8928892/1742424
以上是关于Linux下生提取一年中的周一和周日的主要内容,如果未能解决你的问题,请参考以下文章
oracle怎么查询上周的数据(例如今天是周日,我要查询出上个周一到周日的数据)