Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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
            1)
             hd=`/home/admin/$un` #40
             echo -e "your home dirctory $hd1 " ;;
            2)
             echo -e "Please insert name your home dirctory between 1 to 10 character:"
            read -a hda
            len1=${#hda}
            if [ "$len1" -eq "$ze" ];then
             echo "There is no Argument home dirctory" # error message
 2          exit
            fi
            if [ "$len1" -ge "$te" ];then #50
             echo "The argument home dirctory  maximum 10 alphanumeric" # error message
 3          exit     
            fi
            hd=`/home/admin/$hda`;;
            *) echo " You have selected wrong Choice!!!" ;;
    esac
share|improve this question
    
You probably want to use a while loop. –  Kris Harper Oct 31 '11 at 15:36

1 Answer 1

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"
        ;;
    esac
done
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

 
discard

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.