title: using head -n within if condition
body: <p>I am currently trying to evaluate txt-files in a directory using bash. I want to know if the third line of the txt-file matches a certain string. The file starts with two empty lines, then the target string. I tested the following one liner:</p>
  
  <pre><code>if [[ $(head -n 3 a_txt_file.txt) == "target_string" ]]; then echo yes; else echo no; fi
  </code></pre>
  
  <p>I can imagine that since <code>head -n 3</code> also prints out the two empty lines, I have to add them to the if condition. But <code>"\n\ntarget_string"</code> and <code>"\n\ntarget_string\n"</code> also don't work.</p>
  
  <p>How would one do this correctly (And I guess it can be done more elegantly as well)?</p>