• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

question about C Shell and Bourne Shell string comparisons

hi guys

so im trying to compare two strings in terms of lexical order

for example

if i set VAR1="hi"
and then i set VAR2="bye"

and compare them, so for instance if the snippet of code looks like this:

######################################
set VAR1="hi"
set VAR2="bye"

if [ $VAR1 \< $VAR2 ] ; then
echo "$VAR1 is lexically less than $VAR2"
else
echo "$VAR1 is lexically greater than $VAR2"
fi
exit 0

######################################

when i run the program, the shell interpreter cannot identify the "<" operator
in general the "<" operator is a redirect operator, but i found a site that says if you
use the forward slash it'll interpret it as a string comparison operator.

while running that code i'm not running it on a c shell or bourne shell, but on a tcshell
because that's the only shell i have access to, but can somebody confirm that using \< should allow somebody to compare two strings lexically.

thanks in advance
 
Back
Top