![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| If statement - How to write a null statement | april | Shell Programming and Scripting | 3 | 04-16-2008 10:14 AM |
| Using write() with integers in C | h@run | High Level Programming | 2 | 02-11-2008 11:46 AM |
| Add non-integers using ksh | 2dumb | Shell Programming and Scripting | 17 | 04-30-2007 10:55 AM |
| how do you represent non integers in a shell script? | TRUEST | UNIX for Dummies Questions & Answers | 2 | 05-17-2003 10:00 PM |
| Check if argument passed is an integers | elchalateco | Shell Programming and Scripting | 13 | 11-07-2002 06:23 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
integers in the if statement
hi, im trying to compare two variables in csh to put in an if statement, eg:
set a = $firstnum set b = $secondnum if ($a -ge $b) echo $a But I get an error ("if: Expression syntax"). How can I make csh see my variables as integers? thanks in advance! |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
Your code have the syntactical errors
if [ $a -ge $b ] then echo $a fi Enjoy.... Anji |
|
#3
|
|||
|
|||
|
im using csh, this has always been the form of if that i have been using...
|
|
#4
|
|||
|
|||
|
You should use greater than symbol
if ($a > $b) echo $a
|
|
#5
|
|||
|
|||
|
thanks ranjithpr! it works. it was my first instinct to do that but the "-gt" was what the man pages indicate. i should have tried that one.
|
|
#6
|
|||
|
|||
|
if ( $a -ge $b) then
echo $a endif |
|||
| Google The UNIX and Linux Forums |