您的位置:首页 > 运维架构 > Shell

shell实例 ----判断输入的用户名是否存在与/etc/passwd中

2012-02-10 10:12 447 查看
#!/bin/bash

if [ $# -le 0 ]; then

echo "Please input the right arg"

else

i=`cat /etc/passwd | cut -f1 -d':' | grep -w "$1" -c`

if [ $i -le 0 ]; then

echo "User $1 is not in th passwd"

else

echo "user $1 is in the passwd"

fi

fi
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: