title: Merge files with AWK while adding separators before and after
body: <p>I am attempting to do the following, using AWK:</p>
  
  <ul>
  <li>Read a series of files from a folder.</li>
  <li>Merge all of them into a single file.</li>
  <li>While doing that, I want to place a separator at the beginning <em>and the end</em> of every file (actually a block of code, opening and closing tags, but in this example I use a simple separator for clarity).</li>
  </ul>
  
  <p>What I want to see in my output:</p>
  
  <pre><code>--Separator : Beginning of File--
    ((Content of file1.txt))
  --Separator : End of File--
  --Separator : Beginning of File--
    ((Content of file2.txt))
  --Separator : End of File--
  --Separator : Beginning of File--
    ((Content of file3.txt))
  --Separator : End of File--
  </code></pre>
  
  <p>etc...</p>
  
  <p>I have this code snippet, that works for the "Beginning of File" separator:</p>
  
  <pre><code>INPUT="../folder/*.txt"
  OUPUT="../output.txt"
  
  awk 'FNR==1{print "--Separator : Beginning of File--"}{print}' $INPUT &gt; $OUTPUT
  </code></pre>
  
  <p>Now I'm trying to figure out the next step: detect the end of each file, and put a separator there.</p>
  
  <p>I found a couple of examples that work with END for single file operations, but they only detect the last line <em>of the last file</em>.</p>