1

这是我当前的代码:

 if [ $(getent group administrators) ]; then
   echo "Group exists"
 else
   echo "Group does not exist"
 fi

我的问题是:

  • 如何通过使其包含更多要显示的组来改进它?

  • 并显示组例如管理员,出现在回声中如:组管理员,学生是否存在?

4

1 回答 1

0

用于&&测试多个条件。

if [ $(getent group administrators) ] && [ $(getent group students) ]
then
    echo The groups administrators and students exit
else
    echo The groups administrators and students do not both exist
fi
于 2016-07-24T13:44:57.680 回答