Skip to content

Instantly share code, notes, and snippets.

@geekbass
Created October 12, 2017 13:31
Show Gist options
  • Save geekbass/ad43f0ea1051d660c71fcf9163db0080 to your computer and use it in GitHub Desktop.
Save geekbass/ad43f0ea1051d660c71fcf9163db0080 to your computer and use it in GitHub Desktop.
Check to see if a User exists. If so break with the check on move on.
#!/bin/bash
COUNTER=0
USER='blah'
while [ $COUNTER -lt 10 ]; do
if [ `id -u $USER 2>/dev/null || echo -1` -ge 0 ]; then
echo 'User Found... Moving on...'
break
else
echo 'User Not Found... Retrying...'
sleep 2
fi
let COUNTER=COUNTER+1
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment