Looking for command to compare two strings

Andy Green andy at warmcat.com
Sat Dec 2 13:11:42 UTC 2006


Paul Smith wrote:
> Dear All
> 
> Is there some command to automatically check whether the two following
> strings are equal?
> 
> e64829764ecc434be937d92ab3a00f57
> e64829764ecc434bg937d92ab3a00f57

[b]ash can do it easily enough, eg save this as say isequal

#!/bin/sh

if [ "$1" = "$2" ] ; then echo "same" ; else echo "different" ; fi


make sure you

chmod +x isequal

then you can go, eg

./isequal e64829764ecc434be937d92ab3a00f57 e64829764ecc434bg937d92ab3a00f57

You can use the guts of the script from the commandline, even better

if [ "`md5sum $1`" = "`md5sum $2`" ] ; then echo "same" ; else echo 
"different" ; fi

-Andy




More information about the fedora-list mailing list