Simple Even or Odd Script (Again)- Bourne Shell

okay i thought for sure that would've fixed everything (last question i asked) but I'm getting a new error

it says:

Enter an even or odd number:
2
0          //just wanted to make sure the expr works, which it does
line 6: if[ 0 -eq 0 ]: command not found
line 7: syntax error near unexpected token `then'
line 7: `then'



sigh need help still =(

edit: correct code attatched now
echo 'Enter an even or odd number:'
read num
rem=`expr $num % 2`
echo $rem
if[ $rem -eq 0 ]
then
 echo even
else
 echo odd
fi

Open in new window

nocturn4lAsked:
Who is Participating?
 
imaki06Connect With a Mentor Commented:
There should be a space after the 'if':
if [ $rem -eq 0 ]
0
 
nocturn4lAuthor Commented:
oh and whether i put:

"$rem" or $rem with or without quotes it doesn't seem to matter
if[ "$rem" -eq 0 ]

Open in new window

0
 
ozoConnect With a Mentor Commented:
if [ $rem -eq 0 ]
then
 echo even
else
 echo odd
fi
0
 
nocturn4lAuthor Commented:
it worked for real this time....thanks a million.. was getting so stressed over such a simple program =(
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.