Edgar Cole
asked on
Comparing Korn Shell Variables
Is there a simple way to compare the value of two Korn shell variables, and when the value of the second is larger, assign that value to the first? So, if the value of VAR2 is greater than the value of VAR1, set VAR1 equal to VAR2.
ASKER
Yep, that would do it. Do I feel stupid. I guess I was just feeling lazy today. :-)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
[[ $VAR2 -gt $VAR1 ]] && VAR1=$VAR2
For a string comparison:
[[ "$VAR2" > "$VAR1" ]] && VAR1="$VAR2"
"man test" explains all test operators.