code: public static long getGidFromGroupName(String groupName) throws IOException {
      String result = "";
      if (OSUtils.isLinux()) {
        String script = "getent group " + groupName + " | cut -d: -f3";
        result = ShellUtils.execCommand("bash", "-c", script).trim();
      } else if (OSUtils.isMacOS()) {
        String script = "dscl . -read /Groups/" + groupName
            + " | awk '($1 == \"PrimaryGroupID:\") { print $2 }'";
        result = ShellUtils.execCommand("bash", "-c", script).trim();
      }
      try {
        return Long.parseLong(result);
      } catch (NumberFormatException e) {
        LOG.error("Failed to get gid from group name {}.", groupName);
        return -1;
      }
    }
docs: Retrieves the gid of the given group.
  
  @param groupName the group name
  @return gid