Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SHELL

linux check if a group exist or not

cat /etc/group | grep GROUP_NAME 1> /dev/null
echo $? #result 0 or 1

#or

if ! cat /etc/group | grep $1 1> /dev/null
then
	echo "Error! $1 doesn't exist!"
else
  	echo "$1 group exist!"
fi
 
PREVIOUS NEXT
Tagged: #linux #check #group #exist
ADD COMMENT
Topic
Name
3+8 =