title: How to compare a variable to a string in bash?
body: <p>here is how i tried it</p>
  <pre><code>while IFS= read line 
  do
      var=$(cut -d &quot;:&quot; -f 3 $line)
      if [ &quot;$var&quot; = &quot;L2&quot; ]
      then :here is my action:
      fi
  done &lt; myfile.txt
  </code></pre>
  <p>What i want to do is read a file line by line, read the third word of each line, and do a special action if the third word = a certaine string, i've tried a lot of syntax but it doesn't work. i've also tried to echo &quot;$var&quot; just to see if my variable get the right value, and it does. i don't know what to do anymore</p>