![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| multiple conditions in if using && operator | codeman007 | Shell Programming and Scripting | 2 | 12-30-2008 04:59 PM |
| Perl Substition with multiple conditions | EDALBNUG | UNIX for Dummies Questions & Answers | 4 | 09-25-2008 04:15 PM |
| Multiple conditions in find or ls stmts | mavsman | UNIX for Dummies Questions & Answers | 5 | 04-01-2008 05:57 PM |
| multiple conditions in if/then | grandtheftander | UNIX for Dummies Questions & Answers | 4 | 07-21-2006 02:58 PM |
| multiple conditions in if statements | tim mauger | Shell Programming and Scripting | 3 | 04-28-2002 10:42 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
multiple if conditions
Guys, Im trying to have a script that evaluates multiple conditions : Code:
test.sh: if [ $1 = "brazil1" ] then echo "host $1" else if [ $1 = "brazil2" ] then echo "host $1" else echo $1 not valid exit 1 fi when I do Code:
./test.sh brazil1 I get: Code:
./test.sh: line 12: syntax error: unexpected end of file I'm not sure what I'm doing wrong, could you give me a hand on it please? Thanks Last edited by bashshadow1979; 04-21-2009 at 02:32 PM.. |
|
||||
|
Multiple conditions
Im sorry for not using the code tag, I will next time
What I'm trying to do is to have a script where I can send one parameter and based on that parameter execute a function. if the script received brazil1 then echo something, if it receives brazil2 then echo something else.. etc.. etc.. Thanks guys, I'm sorry for the dumb question but I cant figure it out.. |
|
||||
|
I don't see you put in the second 'fi' yet at the end so I'll change the second else to 'elif' for you: Code:
if [ $1 = "brazil1" ]; then echo "host $1" elif [ $1 = "brazil2" ]; then echo "host $1" else echo $1 not valid exit 1 fi |
|
||||
|
Quote:
Code:
case $1 in "brazil1") # do this ;; "brazil2") # do that ;; *) # oops ;-) ;; esac (background information) |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|