Guessing a digital shell script in Linux

Source: Internet
Author: User

Use the time of the Linux system in the second 1-59 to guess the number game, the detailed code is as follows:

#!/bin/bash#author wangning#date 2017-7-15#qq 1198143315#email [email protected]##### ############################## #define  color######################### #red = "\033[31m" green= "\033[32m" Yellow = "\033[33m" color= "\033[0m" ##################### #check  number if conform 1-59############## ######### #check_number () {expr  $num 1 + 1 &>/dev/nullif [ $? -ne  0 ];then   echo -e  "please input  $red  number  $color"     continue 1elif [ -z  $num 1 ];then   echo -e  "$ Yellow can ' t be empty  $color    continue 2elif [  $num 1  -gt 59 ];then   echo -e  "$green  can ' t great than 59   $color "   continue 3fi}############################### #guess  number ###### #################### # # # #guess_number () {if [  $num 1 -gt  $num  ];then   echo -e  "   $yellow  too big  $color "elif [  $num 1 -eq  $num  ];then    echo -e  "$green  congratulation, you  have guessed !  $color" elif [  $num 1 -lt  $num  ];then   echo -e  "$green  too  small  $color "fi}############################## #while  circulation############################## # #main () {while truedonum=$ (date +%s) read -p  "please input number 1-59:"  num1check_numberguess_numberdone}main


This article is from the "Galloping Camel" blog, make sure to keep this source http://wn2100.blog.51cto.com/9915310/1947812

Guessing a digital shell script in Linux

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.