title: How to split a YAML into multiple files with a proper name
body: <p>I have a valid YAML:</p>
  
  <pre><code>---
  name: first
  metadata: a
  ---
  name: second
  metadata: b
  ---
  name: third
  metadata: c
  </code></pre>
  
  <p>How can I split it using a one-liner AWK script in files <code>first.yaml</code>, <code>second.yaml</code> and <code>third.yaml</code>? Solution needs to work with any <code>name</code>.</p>
  
  <p>Just splitting the file works but I can't figure out how to add proper file names instead of line numbers (<code>NR</code>):</p>
  
  <pre><code>awk '/\-\-\-/{f=NR".yaml"}; {print &gt;f}'
  </code></pre>