Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 537
  • Last Modified:

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

0
nocturn4l
Asked:
nocturn4l
  • 2
2 Solutions
 
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
 
imaki06Commented:
There should be a space after the 'if':
if [ $rem -eq 0 ]
0
 
ozoCommented:
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

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now