<p><strong>NOTE</strong>: this is I think a bash question, not kubernetes or kubectl</p>
<p>I can run the following:</p>
<pre class="lang-bash prettyprint-override"><code>kubectl get pods -n myspace -w
</code></pre>
<p>which will &quot;watch&quot; and provide a stream of lines with e.g. pod name, ready count, status, restarts, and age</p>
<p>similarly I can run</p>
<pre class="lang-bash prettyprint-override"><code>kubectl get pods -n myspace -w -o json
</code></pre>
<p>which will provide more fine-grained change info.  I note that the end of a json block appears to be an unindented <code>}</code> and an unindented <code>{</code> next begins the following block.</p>
<p>my question is, how could I pipe the above to write individual files based on either a new line, or an unindented <code>{</code>?</p>
<p>If there <em>is</em> a native kubernetes way to do that that <em>does not</em> involve extensions or plugins this would be a viable solution though I would prefer a pure bash command-line solution.</p>

<p>You could convert each object into a single line json object with <code>jq</code>:</p>
<pre><code>i=0;
while read line; do
  i=$(($i+1)) 
  echo &quot;$line&quot; &gt; &quot;$i.json&quot;
done &lt; &lt;(kubectl get pods -w -o json | jq -rc '.')
</code></pre>
