1

I have the following shell script

echo "please enter user name: "
read USER_NAME

while [ ! "$USER_NAME" ]
do
echo "User name can't be empty please re-enter: "
read USER_NAME
done

How can I do the same using commands on command line?

2
  • 2
    stackoverflow.com/questions/3061036/…
    – g_p
    Feb 3, 2015 at 10:32
  • 1
    Anything that works in a script works on the command line (at least I can not think of an exception right now). So just type it on the command line. The commandline essentially just prompts you to enter a shell script line by line.
    – Adaephon
    Feb 3, 2015 at 10:48

1 Answer 1

0

You could use while [ "$USER_NAME" == "" ] ... or while [ -z $USER_NAME ].

Not the answer you're looking for? Browse other questions tagged or ask your own question.