码迷,mamicode.com
首页 > 系统相关 > 详细

linux 判断一个用户是否存在

时间:2019-07-07 14:56:31      阅读:128      评论:0      收藏:0      [点我收藏+]

标签:col   ash   inux   inpu   保存   用户   image   img   exist   

#!/bin/bash

read -p "please input a username:" username

if id -u $username >/dev/null 2>&1; then
        echo "user exists"
else
        echo "user does not exist"
fi

把上面内存保存为 test.sh , 然后 sh test.sh 运行

技术图片

linux 判断一个用户是否存在

标签:col   ash   inux   inpu   保存   用户   image   img   exist   

原文地址:https://www.cnblogs.com/dafei4/p/11146114.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!