📜  bash 如果用户存在于组中,则添加 - Shell-Bash 代码示例

📅  最后修改于: 2022-03-11 14:51:07.896000             🧑  作者: Mango

代码示例3
#!/bin/bash
# init
USERID="$1"
#....
/bin/egrep  -i "^${USERID}:" /etc/passwd
if [ $? -eq 0 ]; then
   echo "User $USERID exists in /etc/passwd"
else 
   echo "User $USERID does not exists in /etc/passwd"
fi
# ....