• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 704
  • Last Modified:

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

0
nocturn4l
Asked:
nocturn4l
  • 2
1 Solution
 
woolmilkporcCommented:
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

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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