Answers for "linux check if a group exist or not"

0

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
Posted by: Guest on April-04-2022

Code answers related to "linux check if a group exist or not"

Code answers related to "Shell/Bash"

Browse Popular Code Answers by Language