Results 1 to 6 of 6
I have two md5 strings that i wish to compare. i don't want to do this manually so have been attempting to use either "cmp" or "diff".
I would like ...
- 11-28-2007 #1
comparing standard input
I have two md5 strings that i wish to compare. i don't want to do this manually so have been attempting to use either "cmp" or "diff".
I would like to do it from standard input rather than files.
The best i have come up with so far iswhich compares the operand to STDIN but I was wondering if there was a way to do it with two lots of STDIN (using "cmp" "diff" or any other tool).Code:diff file1 -
- 11-28-2007 #2
- 11-28-2007 #3
thanks for the reply.
i would like to compare two strings rather then files. the following output my make it a bit clearer:
Code:~$ First=f79fa5a676b6dddb5ef48f9041771377 ~$ Second=f79fa5a676b6dddb5ef48f9041771377 ~$ diff $First $Second diff: f79fa5a676b6dddb5ef48f9041771377: No such file or directory diff: f79fa5a676b6dddb5ef48f9041771377: No such file or directory
- 11-28-2007 #4
- 11-29-2007 #5Linux Engineer
- Join Date
- Apr 2006
- Location
- Saint Paul, MN, USA / CentOS, Debian, Solaris, SuSE
- Posts
- 1,117
Hi.
I would use the shell. Get the strings into variables as you need, then compare:
Producing:Code:#!/usr/bin/env sh # @(#) s1 Demonstrate string compare. set -o nounset echo debug=":" debug="echo" ## Use local command version for the commands in this demonstration. echo "(Versions displayed with local utility \"version\")" version >/dev/null 2>&1 && version bash echo First=f79fa5a676b6dddb5ef48f9041771377 Second=f79fa5a676b6dddb5ef48f9041771377 echo " Expecting OK:" if [ "$First" = "$Second" ] then echo OK else echo KO fi echo echo " Expecting KO:" First=9 if [ "$First" = "$Second" ] then echo OK else echo KO fi exit 0
cheers, drlCode:% ./s1 (Versions displayed with local utility "version") GNU bash 2.05b.0 Expecting OK: OK Expecting KO: KO
Welcome - get the most out of the forum by reading forum basics and guidelines: click here.
90% of questions can be answered by using man pages, Quick Search, Advanced Search, Google search, Wikipedia.
We look forward to helping you with the challenge of the other 10%.
( Mn, 2.6.n, AMD-64 3000+, ASUS A8V Deluxe, 1 GB, SATA + IDE, Matrox G400 AGP )
- 11-29-2007 #6


Reply With Quote