title: How to check if a file is empty using awk in a bash script?
body: <p>I am trying to check if a file is empty using <code>awk</code> in a bash script. This condition for a file being empty is the following: If a file only has its first row with field values followed by <code>------</code> (and followed by nothing else) then it is considered empty. </p>
  
  <p>Here is the structure of that special file:</p>
  
  <p>file.txt</p>
  
  <pre><code>col1   col2   col3   col4   col5
  ------
  </code></pre>
  
  <p>So far this is what I have:</p>
  
  <pre><code>awk '
      {
        if (NR &gt; 2)
          print "NOT EMPTY"
        else
          print "EMPTY"
      }
  ' file.txt
  </code></pre>
  
  <p>The output I want is:</p>
  
  <pre><code>EMPTY
  </code></pre>
  
  <p>The empty I am getting is:</p>
  
  <pre><code>EMPTY
  EMPTY
  </code></pre>
  
  <p>How do I get only <code>EMPTY</code> as one output? I know it might be very simple but I couldn't find anything. Thanks!</p>
  
  <p>Let me know if further explanation is needed.</p>
  
  <p>EDIT: Also, if extra blank lines are added to file.txt, then it will print <code>EMPTY</code> for as many extra line there is. Is there a more general approach to this?</p>