Hi,
can someone please help me!!! urgent!
I have a strange issue here. I grep for 2 strings from a txt files and compare the string value. Though the string values are the same, they are compared as different values. Please help
Case-1
--------
Here I grep for 2 different field values and compare them. Though these 2 values are the same in the file, they are compared to be different values and I see the o/p as "Not Equal"
-----
tmp1=`grep Expected samFile.txt | head -1 | cut -d "," -f2 | sed 's/ //g'`
tmp2=`grep Expected samFile.txt | head -1 | cut -d "," -f4 | sed 's/ //g'`
if [[ "$tmp1" = "$tmp2" ]]
then
echo "Equal!!! "
else
echo "Not Equal!!! "
fi
Case-1
--------
Here I manually store these values directly to the variables. In this case, the comparison results is as expected, "Equal"
-----
tmp3=SAMPLE123
tmp4=SAMPLE123
if [[ "$tmp3" = "$tmp4" ]]
then
echo "Equal!!! "
else
echo "Not Equal!!! "
fi
Why didn't the strings were not equal in Case-1??