以下是我希望代码执行的操作的摘要:
if (group exists)
then
(add user to group)
else
(create group)
(add user to group)
fi
我正在使用Ubuntu虚拟机,但我在类似网站上发现的所有结果都不起作用.
以下是我希望代码执行的操作的摘要:
if (group exists)
then
(add user to group)
else
(create group)
(add user to group)
fi
我正在使用Ubuntu虚拟机,但我在类似网站上发现的所有结果都不起作用.
此脚本可能会帮助您:
read -p "enter group name: " group
if grep -q $group /etc/group
then
echo "group exists"
else
echo "group does not exist"
fi
中的换行符