[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.