USAGE="$0 username"
if [[ $# -ne 1 ]]
then
echo "Proper usage: $USAGE"
exit 2
fi
grep $1 /etc/passwd >/dev/null
if [[ $? -eq 0 ]]
then
echo "$1 is a valid user"
exit 0
else
echo "$1 is not a valid user"
exit 1
fi
if [[ $# -ne 1 ]]
then
echo "Proper usage: $USAGE"
exit 2
fi
grep $1 /etc/passwd >/dev/null
if [[ $? -eq 0 ]]
then
echo "$1 is a valid user"
exit 0
else
echo "$1 is not a valid user"
exit 1
fi
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/22661144/viewspace-1430655/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/22661144/viewspace-1430655/