Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SHELL

bash if user exists in a group then add

#!/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
# ....
Source by www.cyberciti.biz #
 
PREVIOUS NEXT
Tagged: #bash #user #exists #group #add
ADD COMMENT
Topic
Name
8+5 =