Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with simple string comparison if statement

Status
Not open for further replies.

linuxMaestro

Instructor
Jan 12, 2004
183
0
0
US
Hi,

I have hardcoded the correct md5sum of /sbin/arp and I want to compare it to the one currently on the server to insure it hasn't been replaced, however it tells me they don't match even though the do. Got any tips?

The script is:
arp="6db3f218870589c77e8dec330ea17222 /sbin/arp"
chkArp=`md5sum /sbin/arp`

echo $arp
echo $chkArp

if [ '$arp' = '$chkArp' ] ; then
echo "/sbin/arp ok"
else
echo "/sbin/arp NOT OK!"
fi

and it yields:
6db3f218870589c77e8dec330ea17222 /sbin/arp
6db3f218870589c77e8dec330ea17222 /sbin/arp
/sbin/arp NOT OK!

Why does my if statement fail?

Thanks in advance.
 

Since there is an embedded space in the strings, I believe he needs double quotes.

Note: Single quotes prevent variable expansion; double quotes allow it, but preserve whitespace.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top