Write a script:
1. Use function to realize:
To determine whether a user exists, the user name passed through the parameters;
If present, the shell and UID of this user are displayed
If it does not exist, it is said that the user does not exist;
2, prompts the user to enter the user name, then passes it to the above function;
3, not exit after the judgment, but prompts the user to continue to enter other user name, or input (quit) exit;
No nonsense, the code is as follows:
#!/bin/bash
#Author: MOS
#Script name:funUinfo.sh
#Date & time:2012-10-09/21:06:02
#Version: 1.0.1
#Description:
#
#定义函数
Find_u () {
#判断输入值是否为空, if null, function ends, return value 1 [-
Z $] && Return 1
#判断用户是否存在, exists to display the request, does not exist, the function ends, returns a value of 1
if ID &>/dev/null then
echo "" Is ' id-u '
echo "Shell is ' grep" ^$1: "/etc/passwd \
|cut-d ': '-f7 '"
else return
1
fi
}
#循环执行 to Meet the topic requirements while
:;d o
read-p "Please input A username[quit to exit]:" User
if [$User = Quit];then
exit 0
Else
find_u $User
res=$?
[$Res-eq 1] && echo "No such $User."
Fi done