Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need back from 2 or 3 to 1 after print error ??

 1      echo -e "program set defulte home dirctory /home/admin/$un"
        echo -e "DO you want use defulte home dirctory? Yes=1 & NO=2"
    read -a hd1
    case $hd1 in
             hd=`/home/admin/$un` #40
             echo -e "your home dirctory $hd1 " ;;
             echo -e "Please insert name your home dirctory between 1 to 10 character:"
            read -a hda
            if [ "$len1" -eq "$ze" ];then
             echo "There is no Argument home dirctory" # error message
 2          exit
            if [ "$len1" -ge "$te" ];then #50
             echo "The argument home dirctory  maximum 10 alphanumeric" # error message
 3          exit     
            *) echo " You have selected wrong Choice!!!" ;;
share|improve this question
You probably want to use a while loop. – Kris Harper Oct 31 '11 at 15:36

Use a while-loop to keep the question running and break out of it when done as shown below

while :; do  # : evaluates to true, so "while true; do ...; done"
    echo "Choose A or B"
    read answer
    case "$answer" in
      [Aa]) # match case-insensitive A
        echo "A was chosen"
        break    # leave the while-loop
      [Bb]) # match case-insensitive B
        echo "B was chosen"
        break    # leave the while-loop
        echo "Please choose A or B only"
share|improve this answer
thank you """ but in choose 2=no in my ask i m check argument enter from user between 0 to 10 character if wrong back to return choose 1 or 2 – Beginners Oct 31 '11 at 16:46
It looks like you're using Google Translate, I can hardly understand you. Carefully look at my code, you should be able to figure out how to implement the logic. break will prevent from asking a question again. – Lekensteyn Oct 31 '11 at 16:59

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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