提示用户输入用户名查看用户详细信息

#!/bin/bash
#
read -p "Input username: " username

while :;do
cat << EOF
U|u) show UID
G|g) show GID
S|s) show SHELL
Q|q) quit.
R|r) Re-select the user.
EOF
judge_user=`id -u $username &>/dev/null`
if [ $? -ne 0 ];then
echo "input user does not exist"
read -p "Input username: " username
else
read -p "Your choice: " choice
case $choice in
U|u)
id -u $username
;;
G|g)
id -g $username
;;
S|s)
bash=`grep "$username" /etc/passwd | awk -F : '{print $7}'`
echo "bash is $bash"
;;
Q|q)
break
;;
R|r)
read -p "Input username: " username
;;
*)
echo "Input parameter is incorrect"
continue
esac
fi
done

原文地址:https://www.cnblogs.com/sjie0224/p/6842333.html