Re: Looking for command to compare two strings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, 2006-12-02 at 14:31 +0000, Paul Smith wrote:
> On 12/2/06, Andy Green <andy@xxxxxxxxxxx> wrote:
> > > 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
> 
> Thanks, Andy. Is not there a native Linux command to compare strings?
> 
> Paul
> 
You are highlighting the real flexibility of Linux (and Unix). From you
were told you could create a command to do this in just a few minutes.

For things like this writing your program is so trivial that it is not
considered worthwhile to have a program to do it.

For example one of the first things a do when installing version of
Linux is to create a command called inst to do: rpm -qa |grep <rpm name>
--
=======================================================================
The meek shall inherit the earth; but by that time there won't be
anything left worth inheriting.
=======================================================================
Aaron Konstam telephone: (210) 656-0355 e-mail: akonstam@xxxxxxxxxxxxx


[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux