String handling is not working inside if loop

Hi All,
I am comparing two strings inside an if condition if the strings are same then it should go inside the loop else it should execute code given in else part.

But there is a but inside my script

Even if the if condition is true
it is not going inside the loop also it is executing the else part.

Please advice

My code:

 
jvm=`cat /tmp/highcpu | awk -F" " '{print $3}' | sed 's/Cl/\/Cl/g' | head -1`
cd /logs/$jvm
thread1=$( cat websphere_stdout.txt | sed -n "/`cat /tmp/thrd_id | head -1`/p" | awk -F" " '{print $4}' |sed  -e 's/tid=//g' -e 's/0x//g' )
thread2=$( cat /tmp/thrd_id | head -1| sed 's/0x//g' )
echo "$thread1"
echo "$thread2"
if [ "$thread1" = "$thread2" ] ; then
  echo "Thread location is $jvm and thread id is `cat /tmp/thrd_id | head -1` >> /tmp/thread_causing_problem
  cat websphere_stdout.txt |sed -n "/`cat /tmp/thrd_id | head -1`/,/\"/p"  >> /tmp/thread_causing_problem
else
  echo "Thread location is $jvm and thread id is `cat /tmp/thrd_id | head -2 | tail -1` >> /tmp/thread_causing_problem
cat websphere_stdout.txt |sed -n "/`cat /tmp/thrd_id | head -2 | tail -1`/,/\"/p"  >> /tmp/thread_causing_problem
fi

Please advice where i am going wrong?

Thanks

change the "=" to "==" . by the way, your code has a lot of processing overheads.

Hey ghost,

Thanks for your quick reply.
But i tried that also

if both the strings are equla
it goes inside the loop

and prints the first line i.e echo

Then in the second line it has to cat the websphere_stdout.txt file and check for particular word and redirect the output to /tmp/thread_causing_problem
but my problem is when i am running the script it is just printing the whole line

cat websphere_stdout.txt |sed -n "/`cat /tmp/thrd_id | head -1`/,/\"/p" >> /tmp/thread_causing_problem

as it is ....why is it not executing this line after executing echo line??

haha,

you are just missing the ending "
echo "Thread location is $jvm and thread id is `cat /tmp/thrd_id | head -1` " >> /tmp/thread_causing_problem

ooops,
That was very stupid of me...

Thanks plyl for letting me know.. ;-))