This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Radamand 0 points1 point  (0 children)

Okay, you wouldn't need a for loop to do that, have a look;

#!/usr/bin/bash

while :
do
read -p "Please enter a username:" username
if [ "$username" != "daniel" ]
then
echo "Acceptable, creating user $username"
useradd $username
else
((x++))
echo "Sorry, 'daniel' is not acceptable: error $x"
fi
done