Shell Script Landscaping Login Interface decoration chart (including lunar calendar) _linux shell

Source: Internet
Author: User

Today colleagues idle, asked me to help in the Linux login page to add something he thinks is very unique, look at his hair, said to him is very silent, below to see.

Script 1:

Cat clcal.sh

#!/bin/bash # show Chinese lunisolar calender. # 2011/11/24 # licensed under GPL version 3 # #日期数据 {{# Calendar_data format: # +--------+---------+--------------+-  -----------+---------+ # | unit (BIT) |   1-4 |   5-16 | 17 |
18-20 | # +--------+---------+--------------+------------+---------+
# | Description | Leap Month |  Monthly Size Month | month of leap months |
Empty | # +--------+---------+--------------+------------+---------+ calendar_data= (0x04bd8 0x04ae0 0x0a570 0x054d5 0x0d260 0x0d950 0x16554 0x056a0 0x09ad0 0x055d2
0x04ae0 0x0a5b6 0x0a4d0 0x0d250 0x1d255 0x0b540 0x0d6a0 0x0ada2 0x095b0 0x14977
0x 04970 0x0a4b0 0x0b4b5 0x06a50 0x06d40 0x1ab54 0x02b60 0x09570 0x052f2 0x04970
0x06566 0x0d4a0 0x0ea50 0x06e95 0x05ad0 0x02 b60 0x186e3 0x092e0 0x1c8d7 0x0c950
0x0d4a0 0x1d8a6 0x0b550 0x056a0 0x1a5b4 0x025d0 0x092d0 0x0d2b2 0x0a950 0x0b557
0x06ca 0 0x0b550 0x15355 0x04da0 0x0a5b0 0x14573 0x052b0 0x0a9a8 0x0e950 0x06aa0
0x0aea6 0x0ab50 0x04b60 0x0aae4 0x0a570 0x05260 0x0f263 0x0d950 0x05b57 0x056a0 0x096d0 0x04dd5 0x0a4d0 0x0d4d4 0x0d250 0x0d558 0x0b540 0x0b6a0 0x195a6
0x095b0 0x049b0 0x0a974 0x0a4b0 0x0b27a 0x06a50 0x06d40 0x0af46 0 x0ab60 0x09570
0x04af5 0x04970 0x064b0 0x074a3 0x0ea50 0x06b58 0x055c0 0x0ab60 0x096d5 0x092e0
0x0c960 0x0d954 0x0d4a0 0x0 da50 0x07552 0x056a0 0x0abb7 0x025d0 0x092d0 0x0cab5
0x0a950 0x0b4a0 0x0baa4 0x0ad50 0x055d9 0x04ba0 0x0a5b0 0x15176 0x052  b0 0x0a930
0x07954 0x06aa0 0x0ad50 0x05b52 0x04b60 0x0a6e6 0x0a4e0 0x0d260 0x0ea65 0x0d530
0x05aa0 0x076a3 0x096d0 0x04bd7 0x04ad0 0x0a4d0 0x1d0b6 0x0d250 0x0d520 0x0dd45
0x0b5a0 0x056d0 0x055b2 0x049b0 0x0a577 0x0a4b0 0x0aa50 0x1b255 0x06d20 0 X0ada0 0x14b63) gan= (' A ', ' B ', ' C ' ding ', ' e ', ' he ' ' Geng ', ' xin ', ' ren ') zhi= (' son ' ugly ', ' I ' ' Chen ', ' I ' am ', ' not ' ' shen ', ' Sheng '  _xiao= (' rat ' ' ox ' ' tiger ' ' Rabbit ' dragon ' ' Snake ' ' horse ' ' sheep ' ' monkey ' ' chicken ' ' dog ' pig ') jieqi_name= (' Xiaohan ' Dahan ') ' Spring ' ' rain ' ' insects ' ' The vernal Equinox ', ' Ching Ming ' ' Gu yu ' Summer ' xiaoman ' ' grain ' ' Summer solstice ', ' slight heat ' ' Great heat ', ' autumn ', ' Chushu ', ' dew ', ' Autumn ', ' dew ', ' frost ', ' Winter ', ' snow ', ' snowy ', ' Winter Solstice ' jieqi_data= (0 21208 42467 63836 85337 107014 128867 150 921 173149 195551 218072 240693 263343 285989 308563 331033 353350 375494 397447 419210 440795 462224 483532 504758) yueri_name1= (' early ' ten ' ' 20 ' ' three ' ' The big ' small ' Rinjita ') yueri_name2= (' Ten ', ' One ', ' two ', ' three ', ' four ', ' five ' ', ' seven ') ' ' eight ', ' nine ', ' ten ', ' 11 ' Wax ' #农历节日 jieri= ([101]= ' spring] [115]= ' Lantern Festival] [505]= ' Dragon Boat Festival ' [707]= ' festivals ' [715]= ' festival ' [815]= ' mid-autumn] [909]= ' heavy sun ' [1208]= ' eight] [1223]= '] [100]= ' New Year's Eve]] # Public Day festival= ([101]= ' New Year's Day ' [214]= ' Valentine's Day ' [308]= '] [312]= ' Day '] [315]= ' Consumer rights days ' [401]= ' April Fools ' ' [501]= ' labour] [504]= ' Youth Festival ' [701]= ' Hong Kong reunification anniversary] [707]= ' Anti-Japanese War Memorial Day ' [801]= ' army ' [910]= ' Teacher's Day ' [918]= ' Jiu Yiba incident] [1001]= ' National holiday] [1002]= ' National Day holiday] [1003]= ' National holiday] [1220]= ' Macau return commemoration ' [1224]= '] Christmas Eve ' [1225]= ' Christmas '] #}} # Lunar calendar month Day calculation function {{# lunar calendar year which month is a leap, no leap is 0 # Which_run_yue Nian which_run_yue () {echo $ (${calendar_dat

A[$1-1900]} & 0xF);} # Number of days in the lunar calendar for a year of the month # days_of_run_rue Nian days_of_run_rue () {($ (Which_run_yue $)) \ && echo $ (${calendar_data[$1 -1900]} & 0x10000?30:29) \ | | echo 0} # Days of the lunar calendar year # Days_of_nian Nian Days_of_nian () {Local nian=$ (($1-1900)) LocAl sum=0 for ((i=0x8000; i>8; i>>=1)); Do ((${calendar_data[$nian]}& $i)) && ((sum++)) did echo $ (($sum +$ (days_of_run_rue $ +348))} # show Ganzhi Name # Show_ganzhi Ganzhi_num Show_ganzhi () {echo ${gan[$1%10]}${zhi[$1%12]}} # is a Gregorian leap year # Is_bissextile year Is_bissext
Ile () {(($1%4 = = 0 && $1%100!= 0) | | $1%400 = 0)) && return 0 | | |-RETURN 1} # The number of days before the beginning of the calendar year to January, January ignored # sum_to_premonth Year Month Sum_to_premonth () {local sum=$ ($2-1? ( $2-1) *30:0)) for ((I=1; i<= ($2-1); i++)); Do case $i in 1|3|5|7|8|
      10|12) ((sum++));;
    2) ((sum-=2)) && Is_bissextile $ && ((sum++)) Esac done Echo $sum} # Calculates the difference of two Gregorian days # sub_two_date laterdate earlydate sub_two_date () {Local year1=${1:0:4} lo Cal Year2=${2:0:4} # Two days to the beginning of the year subtract and add 365/366 sum=$ (($ (sum_to_premonth $year 1 10#${1:4:2}) +365-\ $ (sum_to_premont H $year 2 10#${2:4:2})) Is_bissextile $year 2 && ((sum--)) (sum+=10#${1:6:2}-10#${2:6:2})) # Leap year 365+1 for ((i=year2+1; i<year1; i++)); Do Is_bissextile $i && ((sum++)) Done if ((YEAR1-YEAR2) >0); Then ((sum+= (year1-year2-1) *365)) elif ((YEAR1==YEAR2)); Then ((sum-=365)) Else echo "input is error." && exit Fi $sum} # The Nth solar terms for a certain year in the Gregorian calendar (from 0 Xiaohan) # which_day_is_jieqi years n Which_day_is_jieqi () {Local day S_of_permonth= (0/a) is_bissextile && (days_of_permonth[2]++) # January 1900 6 (a) Day 2:05 for Xiaohan, accurate to sub-calculated local a=$ ((525948* ($1-1900)-$ (sub_two_date ${1}0106 19000106)) # if Small Cold and before 00 o'clock on 6th, days minus 1 local c=$ (($a/(24*60) +6)) (($a <0)) && ((c--)) for ((i=0;i<13 && c>28;i++)) ; 
  Do ((c-=${days_of_permonth[$i]}) the Done Echo $c} # Calculates the Lunar calendar Day calc_cal () {local Run_yue var1 local is_run_yue=0 Local percalc_val= (0 18279 36529) Local all_days=$ (($ (sub_two_date $19000131)) # Here is an optimization algorithm that calculates the estimated value every 50 years to reduce carbon emissions ^_ ^ for ((i=0; i<5; i++)); Do ((${1:0:4}> ($i *50+1900) && ${1:0:4}<= (($i + 1) *50+1900)) && break-Done (All_days-=${perca lc_val[$i])) for ((i= $i *50+1900; all_days>0 && i<2050; i++)); Do var1=$ (Days_of_nian $i) (all_days-= $var 1) is done #--------------------------------------(all_days< 0) && {((all_days+=var1));
  ((i--));} year= $i run_yue=$ (Which_run_yue $i) # TODO is not yet optimized for ((I=1; i<13 && all_days>0; i++)); Do #如果有农历闰月 if ((run_yue>0 && i== (run_yue+1) && is_run_yue==0)); Then ((i)) is_run_yue=1 var1=$ (days_of_run_rue $year) Else var1=$ ((${calendar_data[$year-19 } & (0x10000>> $i)) 30:29) fi (all_days-=var1) (is_run_yue==1 && i==run_yue+1)) && Amp
  
  Is_run_yue=0 Done ((all_days<0)) && {((all_days+=var1));((i--));} if ((all_days==0 && run_yue>0 && i==run_yue+1)); ThEn if ((is_run_yue==1)); Then is_run_yue=0 else is_run_yue=1 ((i)) fi fi month= $i ((day=all_days+1))} #} # Help
 Support and Analysis command line option {{{show_help () {cat <<eof clcal, display Chinese Traditional lunar usage: clcal [-A |-c |-G |-n |-Z |-d date | date] Option: -G display Gregorian calendar year----show the lunar calendar Day----------show the four-column-A, show all items----Do not display lunar calendar-D specify Gregorian month day, format 0 days 00 o'clock-H Show this help EOF exit
    Etopts ' ACD:GHNZ ' Argv;do case, ${ARGV} "in a" show_all=true;;
    c) show_chinese_date=true;;
    d) thisdate= "${optarg}";;
    g) show_date=true;;
    n) donot_show_chinese_calendar=true;;
    z) show_sizhu=true;;
  h) show_help;; Esac Have_arg=true Done (($#==1)) && [[! $HAVE _arg]] && thisdate=$1 #}}} # If you don't have input, use the current year's date thisdate=$ {thisdate=$ (date + "%y%m%d%h")} calc_cal $thisdate # Calculates the four-column {{# # # Year column, which is divided by the beginning of spring, after the beginning of Spring 1900, the Year of nian_zhu=$ (${thisdate:0:4}-1900+ 36) # Adjust the year before the spring ((10#${thisdate:4:2}==2 && 10#${thisdate:6:2}<$ (Which_day_is_jieqi ${thisdate:0:4} 2)) || 10#${thisdate:4:2}==1)) && ((nian_zhu--)) # Month column, to the section (Gregorian calendar month's first solar term for the section, the second for gas) division, January 1900 Xiaohan the day before the month of yue_zhu=$ ((${ thisdate:0:4}-1900) *12+10#${thisdate:4:2}+12) # Adjust the monthly column (10#${thisdate:6:2}<$ (Which_day_is_jieqi ${thisdate:0 : 4} $ ((10#${thisdate:4:2}-1) *2)))) && ((yue_zhu--)) # Day, 23 o'clock the day before 00 o'clock for the night, January 1, 1900 for a Xu Day ri_zhu=$ ($ (sub_ Two_date $thisdate 19000101) +10) # Time Column shi_zhu=$ (((sub_two_date $thisdate 19000101) *24+10#${thisdate:8:2}+1)/2)) #}} # Adjust Display {{{#] to determine the size of the month if ((Is_run_yue)); then month_prefix=${yueri_name1[6]} month_suffix=$ (${calendar_data[$year-19 } & 0x10000?4:5)) Else month_suffix=$ ((${calendar_data[$year -1900]} & 0x10000>> $month? 4:5)) FI # Judge "New Year's Eve "Jieri_index=$ (($month *100+ $day)) if ((month_suffix==4 && jieri_index==1230)); Then jieri_index=100 elif ((month_suffix==5 && jieri_index==1229)); Then jieri_index=100 Fi # determines the solar term (10#${thisdate:6:2}==$ (Which_day_is_jieqi ${thisdate:0:4} $ ((10#${thisdate:4:2}-1) *2 )))) &&\ jieqi=${jieqi_name[$ ((10#${thisdate:4:2}-1) *2)]} (10#${thisdate:6:2}==$ (Which_day_is_jieqi ${

Thisdate:0:4} $ (((10#${thisdate:4:2}-1) *2+1)))) &&\ jieqi=${jieqi_name[$ (((10#${thisdate:4:2}-1) *2+1))]}  # Adjust the date for easy display ((day==10)) && ((day=0)) ((day<10)) && Day=0$day #}} # display Gregorian calendar years [[$SHOW _all | | $SHOW _date ]] && echo ${thisdate:0:4} ${thisdate:4:2} ${thisdate:6:2} # show Lunar calendar [[$SHOW _all | | $SHOW _chinese_date]] & & Echo $year $month $day # Displays Lunar New year, month, day, Lunar festival, solar term, Gregorian festival [[$SHOW _all | | | | $DONOT _show_chinese_calendar]] && Ech o $ (Show_ganzhi $nian _zhu) ${sheng_xiao[nian_zhu%12]} year $month_prefix${yueri_name2[month==1?month+12:month]} month ${ Yueri_name1[month_suffix]}${yueri_name1[${day:0:1}]}${yueri_name2[${day:1:1}]} ${jieri[$jieri _index]} $jieqi ${  Festival[10#${thisdate:4:2}*100+10#${thisdate:6:2}] # show four columns [[$SHOW _all | | $SHOW _sizhu]] && echo $ (Show_ganzhi $nian _zhu) Year $ (Show_ganzhi $yue _zhu) Month $ (Show_ganzhi $ri _zhu) Day $ (show_gAnzhi $shi _zhu) exit # Vi:set ts=2 sw=2 noet: script 2:cat md.sh #!/bin/bash/bin/sh/root/soft_shell/clcal.sh>/roo
                 T/data.txt da= ' Cat/root/data.txt|awk ' {print $} ' cat<<eof _oo0oo_ 088888880 88 ". "88 (|
                 -_- |)   0\ =/0 ___/'---' \___. ' \\\\|
              |// '. / \\\\||| : ||| // \\
              /_ ||||| -:- |||||  - \\
             | |  \\\\\\ - /// |
             | | \_|
             ''\---/'' |_/ | \ .-\__ '-' __/-. /
            ___'. .' /--.--\ '. .' ___
           .""
          ' < '. ___\_<|>_/___. ' > ' "". | | : '- \'.;' \ _ /';.'
          / - ' : | |  \ \ '_. \_ __\ /__ _/  .-' / /
        ====='-.____'.___ \_____/___.-'____.-'=====
                 '=---='
 
 
       ^^^^^^^^^^^

 ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ the ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^ Buddha Bless III never crashes $da EOF

Finally in the crontab to execute regularly:

Crontab-l
1 0 * * */bin/sh/root/soft_shell/md.sh >/ETC/MOTD

Here's what he wants:

In the end, I can only say that it is the idle egg that hurts.

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.