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
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
相关文章推荐
- 提示用户通过键盘输入一个用户名,来判断这个用户是否存在,如果存在就显示一下用户默认的shell
- 提示用户输入一个用户名,判断是否存在,如果存在显示该用户的shell
- shell-用grep查看输入的参数是否在/etc/passwd中
- shell-判断输入的文件是否存在
- AJAX实例应用-1(注册时判断用户名是否存在)
- shell脚本之判断输入参数是否为整数值的实例
- 判断输入用户名是否存在---练习记录
- 使用jquery实现判断用户名是否存在的实例
- shell 要求用户输入一个用户名,查询系统中是否存在该用户,若有打印用户存在,若不存在添加该用户
- 如何判断Javascript对象是否存在的简单实例
- 判断文件目录是否存在的SHELL API
- Shell 判断文件是否存在的方法
- JavaScript判断变量名是否存在数组中的实例
- 关于如何使用ajax异步判断用户名是否存在
- 如何在shell脚本中判断文件或者文件夹是否存在?
- js判断某个方法是否存在实例代码
- 判断文件是否存在的shell脚本代码
- 用shell脚本监控进程是否存在 不存在则启动的实例
- 输入密码或用户名判断是否正确
- shell判断文件是否存在