天天看點

提示使用者輸入一個使用者名,判斷是否存在,如果存在顯示該使用者的shell

vim shell.sh

read -p "please input a username:" MYUSER

if cut -d: -f1 |grep "^$MYUSER$" /etc/passwd &>/dev/null

then

MYSHELL=`grep "^MYUSER" /etc/passwd | cut -d: -f7 `

echo "${MYUSER}'s shell is $MYSHELL"

else

echo "$MYUSER is not exist"

fi

本文轉自 張玉坡 51CTO部落格,原文連結:http://blog.51cto.com/fighter/462778