A random choice at noon where to eat the script, no big use ... Skilled in the use of the shell, welcome to vomit Groove ...

Source: Internet
Author: User

Tag:shell    function     menu print    

[[email protected] scripts]# cat menu.sh #!/bin/bash################################# ## filename: menu.sh# describe: choose a place to eat# author:  lijun# create date: 2015-09-09# version: 1.0##################################[  -f /etc/init.d/functions ] && . /etc/init.d/functionsfunction say ( {  ask= "  Day   mid   noon   I     go   where   &nbsp   eat    rice;?"   answer= "You   say    !  want   not   also   is    with the   machine   Select   Choose  .  .  . ^_^ "  question1= ($Ask)   question2= ($Answer)     for ((i=0;i<=${# question1[*]};i++))   do       echo -ne  "\033[32m${ question1[$i]}\033[0m "      sleep 0.2  done  echo    &nBsp; for ((j=0;j<=${#Question2 [*]};j++))   do       echo  -ne  "${question2[$j]}"       sleep 0.2  done   echo }function info () {    cat << eof====================== =====     The following are information about nearby restaurants:   1. Auspicious wonton (Sutra store)   2. Guilin rice noodles   3. Shaanxi Noodle    4. Old Beijing Noodles Museum ===========================eof}### #Print  menus### #function  menu1 () {     cat << eof***************************  1. Braised noodles with lentils   2. Shrimp Wonton   3. Mushroom chicken wonton   4. Braised beef Noodle ***************************eof}function menu2 () {    cat  << eof***************************  1. Mushroom shredded Pork powder (noodles)   2. Vegetable flour (noodles)   3. Old godmother Fried rice   4. Steamed rice ***************************eof}function menu3 () {    cat  << eof*****************  1. Oil splashing knife noodles   2. Meat bun   3. Tomato Egg knife noodles   4. Cool Skin ************************** *eof}function menu4 () {    cat << eof***************************  1.  only noodles, haha ***************************eof}clearsayfunction time_run () {    for  t in $ (SEQ&NBSP;10|TAC)     do         echo -ne  "${t}...\r in random Processing"         sleep 1     done    echo}echotime_runwhere_num= ' expr  $RANDOM  % 5 ' case   $where _num in    1)       Info       echo -e  "\033[33m Good, we will go to eat wonton today, the following is the menu, choose the same as their own love to eat it!\033[0m"        Menu1      ;; &NBSP;&NBSP;&NBSP;&NBSP;2)       Info      echo -e  "\033[33m good, we will eat Guilin rice noodles today, do not want to run so far, the following is the menu." \033[0m "      Menu2      ;; &NBSP;&NBSP;&NBSP;&NBSP;3)       info      echo  -e  "\033[33m good, we will eat Shaanxi DAO noodles Today, here is the menu." \033[0m "      Menu3      ;; &NBSP;&NBSP;&NBSP;&NBSP;4)       info      echo  -e  "\033[33m haha, it seems that today only to eat noodles." \033[0m "      Menu4      ;;     *)       echo -e   "\033[31m is outside the company area, Delicious places still to be found Oh, sorry ... \033[0m "esacexit 0

The following is the result of the operation:

[[Email protected] scripts]# sh menu.sh Where are we going to eat this noon? You say it or choose it randomly ... ^_^ Random processing 1....=========================== The following are information about nearby restaurants: 1. Auspicious wonton (Buddhist Sutra store) 2. Guilin Rice noodles 3. Shaanxi Noodle Shop 4. The old Beijing Noodles Hall ========================== = OK, let's eat wonton today, here is the menu, choose the same as you love it!*************************** 1. Braised noodles with lentils 2. Shrimp wonton 3. Mushroom Chicken wonton 4. Braised Beef Noodle ************************* **

.... ^_^ ..... Nothing practical, feel the fun, skilled script programming just!

A random choice at noon where to eat the script, no big use ... Skilled in the use of the shell, welcome to vomit Groove ...

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.