title: awk - cannot open file error
body: <pre><code>#!/usr/bin/nawk -f
  
  # Before lines are processed
  BEGIN {
  
  print "Awk Started" &gt;&gt; FILE_STDOUT
  
  # Variables
  rec1=""
  rec2=""
  rec3=""
  rec4=""
  mod=0
  X=23
  
  }
  
   NR % 5 != 0 {
   mod=NR%5
  if (mod==1) 
      rec1=$0
  else
  if (mod=2)    
      rec2=$0
  else
  if (mod=3)   
      rec3=$0
  else 
  if (mod=4)  
    rec4=$0
  
  next
  }
  
  # NR % 5 == 0
  {
  
    if (substr($rec1,9,2)==X || substr($rec2,9,2)==X || substr($rec3,9,2)==X || substr($rec4,9,2)==X)
  {
     print rec1
     print rec2
     print rec3
     print rec4
  }
  }
  
  END {
  
     print "Awk Ended" &gt;&gt; FILE_STDOUT
  
  }
  </code></pre>
  
  <p>While running the above script which is supposed to check blocks of 4 for a specific entry and output them, i get this error :</p>
  
  <blockquote>
    <p>awk: cannot open "" for output (No such file or directory)</p>
  </blockquote>
  
  <p>What's the reason?</p>
  
  <p>Sample input :</p>
  
  <pre><code>    101010201231000
      101010201AA1000
      101010201AA1000
      101010201AA1000
      303030401AA1000
      303030401321000
      303030401AA1000
      303030401AA1000
      505050601AA1000
      505050601AA1000
      505050601431000
      505050601AA1000
      707070801AA1000
      707070801AA1000
      707070801AA1000
      707070801561000
  </code></pre>
  
  <p>Sample output :</p>
  
  <pre><code>101010201231000
  101010201AA1000
  101010201AA1000
  101010201AA1000
  </code></pre>
  
  <p>The error i am given is : </p>
  
  <p>nawk: program limit exceeded: maximum number of fields size=32767
          FILENAME="awktestor.txt" FNR=1 NR=1</p>