Everytime I run my script the following if statement gives me the error;script.sh: [Error==Error]: not foundorscript.sh: [Error==-2]: not foundif [$P1==$P2];then            echo $namefiI've tried other versions    if [$P1==$P2]            then            echo $name    fiand     if [[ $P1 == $P2 ]]            then            echo $namefiP1=ErrorP2=$(sed -n '1p' somefile.txt)somefile.txt might contain a number or a string
bash if statement troubles [Error==Error]: not found
bash
Spaces are significant. Use:if [ $P1 = $P2 ]What went wrongWhen the shell sees [$P1==$P2], it interprets it as a single word and looks for a command that matches that word.  Since no such command exists, you get the not found error message.