LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   how to code a "less than" with strings (https://www.linuxquestions.org/questions/linux-software-2/how-to-code-a-less-than-with-strings-609696/)

Guess 12-28-2007 07:30 PM

how to code a "less than" with strings
 
I have variables of the form

1.0.1a
1.0.2a
1.0.2b

how do I code a greater than or less than for this?

basic I need a

if var1 < "or equal to" var2, then
do stuff
fi

matthewg42 12-28-2007 08:04 PM

Do you have a particular language in mind? In Perl the lt operator will do what you want.

bigrigdriver 12-28-2007 10:03 PM

In bash,
Code:


 -lt (<)  less than
 -gt (>)  greater than
 -le (<=)  less than or equal to
 -ge (>=)  greater than or equal to
 -eq (==) equals
 -ne (!=)  not equal



All times are GMT -5. The time now is 07:51 PM.