Solved

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

Posted on 2011-02-17
3
681 Views
Last Modified: 2013-12-26
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
Comment
Question by:nocturn4l
  • 2
3 Comments
 
LVL 68

Accepted Solution

by:
woolmilkporc earned 500 total points
ID: 34917615
if [ $(($1 % $num)) = 0 -a $(($2 % $num)) = 0 ]

0
 

Author Comment

by:nocturn4l
ID: 34917667
oh wow......thanks gonna check it out right now, i'll be back
0
 

Author Comment

by:nocturn4l
ID: 34917683
it worked!!!  thanks!!
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Background Still having to process all these year-end "csv" files received from all these sources (including Government entities), sometimes we have the need to examine the contents due to data error, etc... As a "Unix" shop, our only readily …
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question