Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

in my linux machine red-hat 5.1 - in ppp file - I have only the string !!!

  • remark - third application write the string in to ppp file

I set ppp file in $a param And compare $a with

But as all see here this not equal - why ? or if I have empty space? How to solve this?

    # more /var/tmp/ppp
    # a=`cat /var/tmp/ppp`
    # echo $a
    # [[ $a = ]] && echo equal


    # [[ $a == ]] && echo equal

diff example that works ! - from ksh shell (LINUX RED-HAT 5.1)

[u@h w]# echo > file
[u@h w]# cat file
[u@h w]# a=`cat file`  
[u@h w]# echo $a
[u@h w]# [[ $a = ]] && echo eq

 its print "eq"
share|improve this question
Your "real" example compares and aren't the same. – Mark Wagner Feb 5 '12 at 3:16
this is a nother example (I fix it), on both they have the same ishhu – Eytan Feb 5 '12 at 4:46
It works for me. What does this tell you? echo "${.sh.version}" What happens if you do: [[ $a = $a ]] && echo eq – Dennis Williamson Feb 5 '12 at 18:26
yes Dennis now its work also for me I create new file in place of ppp , not clearly what was wrong , for for the first case the original question I still have problem - third application write the string in to ppp file so I cant say what wrong here in the ppp file by vi I see only this string ( I update my results on the second case ) – Eytan Feb 5 '12 at 21:09
Run /var/tmp/ppp through od -c - it might contain some unprintables. – Henk Langeveld May 3 '13 at 23:48
up vote 4 down vote accepted

You need two equal signs:

[[ $a == ]] && echo equal
share|improve this answer
I already tried it it also not work .....!!! – Eytan Feb 4 '12 at 23:20

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.