Test brackets... too many arguments.. need help simplifying - Bourne Shell

is there anyway I can simplify this?  ahh only have a like 20 minutes before this is due.. maybe my mind is cluttered but I can't find a way to simplify this statement without bourne shell giving me the argument

line 15: [: too many arguments

line 15 is specifically

if [ $1 % $num = 0 -a $2 % $num = 0 ]
#!/bin/sh
if [ $1 -gt $2 ]
then
num=$1
big=$1
small=$2
else
num=$2
big=$2
small=$1
fi

while [ $num -gt 0 ]
do
if [ $1 % $num = 0 -a $2 % $num = 0 ]
then
echo "GCD is $num"
num=0
else
num=`expr $num - 1`
fi
done

Open in new window

nocturn4lAsked:
Who is Participating?
 
woolmilkporcConnect With a Mentor Commented:
if [ $(($1 % $num)) = 0 -a $(($2 % $num)) = 0 ]

0
 
nocturn4lAuthor Commented:
oh wow......thanks gonna check it out right now, i'll be back
0
 
nocturn4lAuthor Commented:
it worked!!!  thanks!!
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.