LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   3 point if/else statement (https://www.linuxquestions.org/questions/linux-newbie-8/3-point-if-else-statement-714795/)

bioinformatics_guy 03-27-2009 05:22 AM

3 point if/else statement
 
In bash, the only if/else structure I can find is

if [ ] ; then


else


fi

What if I have three things I want to check, such as:

if [ ] ; then


elsif [ ] ; then


else

fi

Does this structure exist or do I just need to do some large nested if/else loop

bioinformatics_guy 03-27-2009 05:28 AM

Found it:

elif

JulianTosh 03-27-2009 05:29 AM

Try the case statement:

http://www.softpanorama.org/Scriptin...tatement.shtml

Code:

case expression in
    pattern1 )
        statements ;;
    pattern2 )
        statements ;;
    ...
esac



All times are GMT -5. The time now is 08:37 AM.