I receive an error: "/bin/ums: 19: [: is_duplicate: unexpected operator" when running the following script:
#! /bin/sh
group=""
#utility functions
is_duplicate () {
return grep $1 /etc/passwd /etc/group
}
#script
echo "Welcome to the user management system."
echo "Please enter the name of the group you wish to create:"
read group
while [ is_duplicate "$group" -eq 0 ]
do
echo "That group name already exists."
echo "Please enter a new name:"
read group
done
Why?
Note: The script is a work in progress. In this segment I am trying to grep for the name of a group being input in the console. If the group exists in the group file (i.e. grep returns exit code 0) then continue asking for a name.