Shell script, a classic topic.

Source: Internet
Author: User

[Email protected] wyb]#CatZhuijiu.SH #!/bin/bash#1, write a script execution, enter a name, generate a random number 01-the number between 99. #2, if the same name repeated input, the captured number is the result of the first crawl, #3, the number that has been caught before, the next time cannot appear the same number. #4, the first input name, the screen output information, and the name and number recorded in the file, the program can not exit, continue to wait for other students to enterfile=file99Echo "Press Q to quit"[ ! -F About. txt] &&seq 1  About> About. Txtrandom () { line=`Cat  About. txt|WC-l ' key=`Echo$ (($RANDOM% $line) +1)) ' A=`sed-N"'$key'P'  About. txt 'sed-I."'$key'D'  About. txt} while : DoRead-P"Please input a name:"name [["$name"="Q"]] &&Break Random B=`grep-C'\<'$name'\>'$file' [$b-ne0] &&grep  '\<'$name'\>'$file|awk '{print $}'&&ContinueEcho$name $a >> $file  Echo$a Done[email protected] wyb]# bash Zhuijiu.SHPress Q to quitplease input a Name:wang1Please input a name:name atPlease input a Name:wang1Please input a name:name atPlease input a name:chen -Please input a name:lisi thePlease input a name:lisi thePlease input a name:

Shell script, a classic topic.

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.