![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| have a problem with if elif loop .. plz help me with the script | Syms | UNIX for Dummies Questions & Answers | 4 | 10-31-2007 11:59 PM |
| IF THEN ELIF question in BOURNE SHELL | arun_st | UNIX for Dummies Questions & Answers | 4 | 04-20-2007 09:41 AM |
| If..elif..else...fi | Rock | Shell Programming and Scripting | 2 | 02-08-2007 03:32 AM |
| elif not expected | pv0428 | Shell Programming and Scripting | 9 | 07-28-2005 01:38 AM |
| if...elif...fi condition in Unix | abidmalik | UNIX for Dummies Questions & Answers | 9 | 09-05-2002 05:35 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Help with ELIF statement
I am receiving an elif error on line 13 and I can not figure out the reasoning behind it. I have added the then statement that I was initially missing. Any help would be great.
#The purpose of this script is for the end user to be able to enter a positive number #User enters a number NUM=$1 #If user enters more than one it will return this statement if [ $# -ne1 1 ] then echo "Only enter one number!" exit #For if the user enters a negative number elif [ $NUM -le 0 ] then echo "Enter a positive number!" fi #Executionary if statement while [ "$NUM" -gt 0 ] do printf $NUM if[ $NUM -gt 1 ] then printf "," fi NUM=$((NUM - 1)) done Thanks |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
You are missing a semicolon before an earlier then. Also -ne is misspelled.
The syntax of the if statement is Code:
if some command or other; then action else otheraction fi |
|
#3
|
|||
|
|||
|
It still shows me as having an issue with the done portion of my while loop at the end, I tried moving the done above and below the last statement but it wont work.
|
|
#4
|
|||
|
|||
|
Did you fix the if inside the while also?
|
|
#5
|
|||
|
|||
|
Nope...that fixed it though.
Thanks. |
|||
| Google The UNIX and Linux Forums |