Re: Looking for command to compare two strings
- From: Gilboa Davara <gilboad@xxxxxxxxx>
- Date: Sat, 02 Dec 2006 17:16:04 +0200
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
It can be done from command line.
$ STR1="hello" ; STR2="world" ; if [ "$STR1" == "$STR2" ]; then echo
Match; else echo No match; fi
No match.
$ STR1="hello" ; STR2="hello" ; if [ "$STR1" == "$STR2" ]; then echo
Match; else echo No match; fi
Match
- Gilboa
--
fedora-list mailing list
fedora-list@xxxxxxxxxx
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
- References:
- Looking for command to compare two strings
- From: Paul Smith
- Re: Looking for command to compare two strings
- From: Andy Green
- Re: Looking for command to compare two strings
- From: Paul Smith
- Looking for command to compare two strings
- Prev by Date: Re: Unable To Boot From a Fedora Core 6 DVD Disk
- Next by Date: Re: Display settings..
- Previous by thread: Re: Looking for command to compare two strings
- Next by thread: Re: Looking for command to compare two strings
- Index(es):
Relevant Pages
|