[Email protected] wyb]#Cat2quan.SH #!/bin/bash# Write a script, first asked to enter a user name, and then let him enter a number, lose if it is a number to output yes, not a number, output no# and then if you enter more than three times is not the number lock this user, is not let him on the # requirements cumulative, even if the script and restart, it is useless, Still locked, the number of times to 3 lock Read_user () {Read-P"Please Input a Username:"Username}read_user while[ -Z $username] DoRead_user Done[ ! -F $username. log] &&Touch$username. Logjudge_user () {Key=`Cat$username. log|WC-l ' [$key-ge3] &&Echo "This $username is lock"&&Exit}judge_userEcho 'input ' quit ' to quit' while : DoJudge_user Read-P"pleas input a number:"Num [-Z $num] &&continue [["$num"="quit"]] && BreakExpr$num +1&>/dev/NULL [ $? -ne0] &&EchoError >> $username. Log &&Echono| |EchoYes Done[email protected] wyb]# bash 2quan.SHPlease input a username:chenginput ' quit ' to quitpleas input a number:eeenopleas input a number:123Yespleas Input a number:123Yespleas Input A number:dddnopleas input a number:aaanothis Cheng is lock[[email protected] wyb]# bash 2quan.SHPlease Input a username:chengthis Cheng is lock[[email protected] wyb]# bash 2quan.SHPlease input a username:jinginput ' quit ' to Quitpleas input a number:123Yespleas Input A number:bbbnopleas input a number:dddnopleas input a number:aaanothis Jing is lock[[email protected] W yb]# bash 2quan.SHPlease input a username:quitinput ' quit ' to quitpleas input a number:quit[[email protected] wyb]#Catjing.log errorerrorerror[[email protected] wyb]#Catcheng.log errorerrorerror[[email protected] wyb]#
Shelll scripts, common script topics.