Sparrow1029

loop

Dec 9th, 2019
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.43 KB | None | 0 0
  1. while true
  2.     do
  3.         echo -n "Enter a UID: "
  4.         read uid
  5.         if [ $uid -le 1000 -o $uid -ge 65537 ]; then
  6.             echo "Invalid number. Range 1000..65537"
  7.             continue
  8.         elif cat /etc/passwd | awk -F':' '{ print $3 }' | grep $uid; then
  9.             echo "UID already exists, please choose another";
  10.             continue
  11.         else break;
  12.         fi
  13.     done
  14.    
  15. echo "Your UID is ${uid}";
Advertisement
Add Comment
Please, Sign In to add comment