想請教如何寫一個BASH SCRIPT create a user and a group(if the group is not exist)
#!bin/bash
read -p "Enter USERNAME: " userNAME
read -p "Enter USERGROUP name: " userRGROUP
grep $USERGROUP /etc/group 2>&1> /dev/null
while [ $? -eq 0 ]
read -p "Enter USERNAME: " userNAME
read -p "Enter USERGROUP name: " userRGROUP
grep $USERGROUP /etc/group 2>&1> /dev/null
printf "Group Name you entered $USERGROUP is not valid\n"
printf "Creating Abort!"\n"
exit 1
do
useradd -g $USERGROUP -d /home/$USERNAME -s /bin/bash -m $USERNAME
passwd $USERNAME
done
id $USERNAME
printf "Done!\n"
exit 0