[Email protected] wyb]#CatTishiuser.SH #!/bin/Bash #提示用户输入一个用户名, if present, displays user UID and shell information, otherwise, #则显示无此用户, prompts the user to enter again after the display is completed, and exits if quit ;Echo 'Input ' quit ' to quit' while : DoRead-P"Please Input a user:"Choice [-Z $choice] &&continue [["$choice"="quit"]] && BreakID$choice &>/dev/NULL [ $? -eq0] &&grep "$choice"/etc/passwd|awk-F":" '{print $, $NF}'||Echo "NO this user!" Done[email protected] wyb]# bash tishiuser.SHinput ' quit ' to quitplease input a user:quit[[email protected] wyb]# bash tishiuser.SHinput ' quit ' to quitplease input a user:root0/bin/Bash One/sbin/nologinplease Input a user:fineday -/bin/bashplease Input a User:bobo501/bin/bashplease Input a user:quit[[email protected] wyb]# bash tishiuser.SHinput ' quit ' to quitplease input a user:llkkno this user!Please Input a user:quit[[email protected] wyb]#
Shell script, prompting the user to enter a user name, if present, displays the user UID and shell information, otherwise, the user is not displayed, the display is completed, prompting the user to enter again, or quit if quit;