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

#!/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

posted @ 2017-05-11 19:19  孤鸟的悲歌丶  阅读(337)  评论(0编辑  收藏  举报