#!/usr/bin/env bash

min_uid=1000

declare -i _id=$(expr $min_uid - 1)

while true ; do
   ((_id++))
   $(id $_id > /dev/null 2>&1) && continue
   $(cat /etc/group | cut -d ':' -f3 | grep -q $_id 2> /dev/null) && continue
   break
done

echo
echo "   Next free uid/gid pair:"
echo
echo -e "      uid: \033[1m$_id\033[m"
echo -e "      gid: \033[1m$_id\033[m"
echo

exit 0

