?
Solved

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

Posted on 2011-02-17
3
Medium Priority
?
691 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 68

Accepted Solution

by:
woolmilkporc earned 2000 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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 …
Utilizing an array to gracefully append to a list of EmailAddresses
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…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Suggested Courses

764 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