2017 the latest enterprise face Test shell (iv)

Source: Internet
Author: User

2017 the latest enterprise face Test shell (iv)


First, the draw script (1) requires the following:

1, write a script execution, enter the name, generate a random number 01-99 between the number;

2, after entering the name, the screen output information, and the names and numbers recorded in the file;

3. If the same name is repeated, the script gives the hint "duplicate name" and asks the student to re-enter it and not record the input into the file;

4, the program can not exit and continue to wait for other students input.

The script image is as follows:

650) this.width=650; "src=" Https://s3.51cto.com/wyfs02/M00/A4/CA/wKioL1mxU1bARQt4AABh1FJW-Po614.png "title=" 22. PNG "width=" "height=" 549 "border=" 0 "hspace=" 0 "vspace=" 0 "style=" WIDTH:500PX;HEIGHT:549PX; "alt=" Wkiol1mxu1barqt4aabh1fjw-po614.png "/>

The script documents are as follows:

#!/bin/shfun0 () {printf "$name $num \ n" >/dev/null}fun1 () {read-p "Please enter your name:" Name}fun2 () {num=$[random%100]echo $ Nameecho $numprintf "$name $num \ n" >>/root/name.txtusleep 2000000#clear}fun1fun2fun3 () {bb=$ (grep "$name"/root/ Name.txt|awk ' {print $} ') if [-Z ' $bb '];then echo ' can use ' else echo ' name repeat && fun0 && mainfi}main () {W Hile Truedo fun1 fun3 fun2done}main

Second, the Draw script (2) requires the following:

1, write a script execution, enter the name, generate a random number 01-99 between the number;

2, after entering the name, the screen output information, and the names and numbers recorded in the file;

3. If the same name is repeated, the script gives the hint "duplicate name" and asks the student to re-enter it and not record the input into the file;

4, the previous number has been captured, the next time can not appear the same number;

5, the program can not exit and continue to wait for other students input.

The script image is as follows:

650) this.width=650; "src=" Https://s1.51cto.com/wyfs02/M00/06/19/wKiom1mxVcmSePtHAACggw8UMVY181.png "style=" width : 700px;height:642px; "title=" 33.png "width=" "height=" 642 "border=" 0 "hspace=" 0 "vspace=" 0 "alt=" Wkiom1mxvcmsepthaacggw8umvy181.png "/>

650) this.width=650; "src=" Https://s3.51cto.com/wyfs02/M02/A4/CA/wKioL1mxVaijLeb0AAAHMeAeKvM214.png "style=" width : 700px;height:58px; "title=" 44.png "width=" "height=" "border=" 0 "hspace=" 0 "vspace=" 0 "alt=" Wkiol1mxvaijleb0aaahmeaekvm214.png "/>

The script documents are as follows:

#!/bin/shfun0 () {printf  "$name   $num \ n"  >/dev/null}fun1 () {read -p  "Please enter your name:"   Name}fun2 () {num=$[ random%100 ]echo  $nameecho   $numprintf   $name   $num \ n   >>/root/name.txtusleep 2000000#clear}fun1fun2fun3 () {bb=$ (grep  "$name"  /root/name.txt|awk   ' {print $1} ') if [ -z  "$BB"  ];then   echo  "can use"  else    echo  "Duplicate name"  && fun0 && mainfi}fun4 () {mm=$ (grep   "$num"  /root/name.txt|awk  ' {print $2} ') if [ -z  $mm  ];then    echo  "can use"  && printf  $name   $num \ n " >>/root/name.txt  && main  else   echo  "Digital Repetition"  && fun0  && mainfi}fun5 () {num=$[ random%100 ]echo  $nameecho   $num}main () {while  Truedo    fun1    fun3    fun5    fun4done}main 


This article is from the "Hand of the Paladin Control" blog, please make sure to keep this source http://wutengfei.blog.51cto.com/10942117/1963545

2017 the latest enterprise face Test shell (iv)

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.