1754986 Members
3442 Online
108828 Solutions
New Discussion юеВ

If sentence ..

 
SOLVED
Go to solution
Manuales
Super Advisor

If sentence ..

hi ..
how cay i use if to indicate a sentence:
if $a (is bigger than) $b
then ...

"is bigger than" how can i indicate it in if sentence? is like -ge? is like -aq? what is, i don't remember it ...!!!

Thanks, Manuales.
27 REPLIES 27
Geoff Wild
Honored Contributor
Solution

Re: If sentence ..

if (( $a > $b ))

Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
Slawomir Gora
Honored Contributor

Re: If sentence ..


if [ $a -gt $b ]
then
...
fi
Peter Godron
Honored Contributor

Re: If sentence ..

Manuales,
if you type man test it will show some useful syntax.
Manuales
Super Advisor

Re: If sentence ..

thanks, buy if you use "test"

if test $a ...... Bb

whad do you put in space "...." ?

Tnanks, Manuales.
Oviwan
Honored Contributor

Re: If sentence ..

ksh:

for strings:
"=" equal
"!=" not equal

for numbers:
"-eq" equal
"-ne" not equal
"-gt" greater than
"-lt" less than

Regards
James R. Ferguson
Acclaimed Contributor

Re: If sentence ..

Hi Manuales:

I assume that you want the Posix (or 'ksh') shell syntax.

If so, see the man pages for 'test' and the man pages for 'sh-posix'.

Regards!

...JRF...
Peter Godron
Honored Contributor

Re: If sentence ..

Manuales,

#!/usr/bin/ksh
a="A"
b="B"
if [[ "$a" > "$b" ]]
then
echo a greater than b
else
echo a not greater than b
fi

Rodney Hills
Honored Contributor

Re: If sentence ..

The "test" command and its equivalent "[ ... ]" syntax are different then the "[[ ... ]]" syntax used in "ksh".

A review of "man test" and "man ksh" will explain the differences.

For instance-
if [ ab = a* ]... is false since it is a string compare, whereas
if [[ ab = a* ]]... is true since it is doing a pattern match.

read the "man" pages for the details...

Rod Hills
There be dragons...
Manuales
Super Advisor

Re: If sentence ..

i'm using csh
why do i have next error?
serverunix:girl1 279> prueba.csh
if: Expression syntax.

my script is:
if ($bb = 1)
then
echo "hola"
else
echo "adios"
eif

why is the problem??

Thanks, Manuales.