Unix Shell - comparision operator

This is Interesting: Free IT Magazines  
Home > Archive > Unix Shell > January 2006 > comparision operator





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author comparision operator
PRadyut

2006-01-13, 10:39 pm

Hi Group,

I'm running Fedora Core 3 with release id 2.6.9-1.667
I have a code that gives a error as
"too many arguments" in the line if [ $per -le 50 -a $ per -lt 60 ]

My code

----------------------Code----------------------------------
echo "enter marks in five subjects"
read m1 m2 m3 m4 m5

per=`expr \( $m1 + $m2 + $m3 + $m4 + $m5 \) / 5`

if [ $per -ge 60 ]
then
echo First division
fi

if [ $per -le 50 -a $ per -lt 60 ]
then
echo Second Division
fi
----------------------------EOF------------------------------

Please explain the output of the code and suggest correcting the code

Thanking You
Pradyut
http://pradyut.tk
http://spaces.msn.com/members/oop-edge/
http://groups-beta.google.com/group/oop_programming
India

William

2006-01-13, 10:40 pm

"PRadyut" <pradyutb@gmail.com> wrote in message
news:1136901929.559377.70970@g47g2000cwa.googlegroups.com...
> Hi Group,
>
> I'm running Fedora Core 3 with release id 2.6.9-1.667
> I have a code that gives a error as
> "too many arguments" in the line if [ $per -le 50 -a $ per -lt 60 ]


Take a really close look at that line. Assuming you cut
and pasted the exact line from you code (or homework, sounds
like), the problem should be obvious. (Hint: spaces count)

-Wm


Ed Morton

2006-01-13, 10:40 pm


PRadyut wrote:

> Hi Group,
>
> I'm running Fedora Core 3 with release id 2.6.9-1.667
> I have a code that gives a error as
> "too many arguments" in the line if [ $per -le 50 -a $ per -lt 60 ]


Yeah, we know, you told us yesterday. You might want to read the
responses you got then too....

Ed.
PRadyut

2006-01-13, 10:40 pm


Ed Morton wrote:
> PRadyut wrote:
>
>
> Yeah, we know, you told us yesterday. You might want to read the
> responses you got then too....
>
> Ed


Sorry there,
My newsreader problem

Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com