in If statement how can i campare
"ASCII" with "ascii"
the result of comparision shold be true.....
in If statement how can i campare
"ASCII" with "ascii"
the result of comparision shold be true.....
here is a case-blind compare function for shell
#/bin/ksh
stricmp()
{
let retval=0
one="$( echo "$1" | tr -s '[:upper:]' '[:lower]')"
two="$( echo "$2" | tr -s '[:upper:]' '[:lower]')"
if [[ "$one" = "$two" ]] ; then
retval=1
fi
return $retval
}
#sample usage
stricmp "ASCII" "ascii"
if [ $? -eq 1 ] ; then
echo "equal"
else
echo "not equal"
fi
Another ksh function :
#/bin/ksh
icmp()
{
typeset -u one="$1"
typeset -u two="$2"
[ "$one" = "$two" ]
}
#sample usage
if icmp "ASCII" "Ascii"
then
echo "equal"
else
echo "not equal"
fi
Jean-Pierre.