<p>How can I separate the logs from one pod to another?
Below is what I worked on:</p>
<pre><code>CrashLoopBackOff=`for i in $(kubectl get po -n namespace | grep CrashLoopBackOff | awk '{print $1}'); do echo $i; done`
for y in $CrashLoopBackOff; do 
    k8s_logs=`kubectl logs $y -n namespace | tail -10` arr2+=&quot;$k8s_logs\n&quot;
done
</code></pre>
<p>But the output is all together for 2 crashed pods or more pods and I cannot differentiate the logs from each pod. Any idea how can I put an echo or something between each pod log?</p>
<pre><code>2021-03-12 07:30:11.622 [ERROR] [gstp_server_app.cc:4007] Failed to start subscription from SEL
2021-03-12 07:30:11.622 [ERROR] [gstp_server_app.cc:4010] Exception:    0 In order to do catch up, static entity: must have history enabled.

2021-03-12 07:30:11.622 [FATAL] [gstp_server_app.cc:1441] JMS Catchup initialization error.
2021-03-12 07:30:11.622 [FATAL] [gstp_server_app.cc:695] Failed to connect to JMS for data
2021-03-12 07:30:13.188 [INFO ] [jms_server.cc:495] End JMSServer.run
Ending JMSServer::Run
GSTP JMS Server Application Shutting down.
255
2021-03-12 07:31:51.828 [ERROR] [rcltocvll.cc:325] Zero Curve does not exist for DEPOT asof 02/06/12.
2021-03-12 07:31:51.831 [ERROR] [gbdopspec.cc:297] Error Creating Curve List Out Of Risk Class 
2021-03-12 07:31:51.831 [ERROR] [sectheo.cc:705] Error retrieving security curves.
2021-03-12 07:31:51.833 [ERROR] [sectheo.cc:999] Error computing theoretical price for Security 
2021-03-12 07:31:51.833 [ERROR] [rcltocvll.cc:325] Zero Curve does not exist for DEPOT asof 02/06/12.
2021-03-12 07:31:51.833 [ERROR] [gbdopspec.cc:297] Error Creating Curve List Out Of Risk Class List
2021-03-12 07:31:51.833 [ERROR] [sectheo.cc:705] Error retrieving security curves.
2021-03-12 07:31:51.833 [ERROR] [sectheo.cc:999] Error computing theoretical price for Security 
bash: line 1:     6 Killed                  gstp_server_jms -N -LOGGER INFO -CFG 
</code></pre>

Sissi_00_20
<p>Please don't forget to give part of <code>kubectl get po -n namespace</code>'s output for people to know what kind of data you are working on.</p>
<p>Also, the backquote (<code>`</code>) is used in the old-style command substitution, e.g. <code>foo=`command` </code>. The <code>foo=$(command)</code> syntax is recommended instead. Backslash handling inside <code>$()</code> is less surprising, and <code>$()</code> is easier to nest. See <a href="http://mywiki.wooledge.org/BashFAQ/082" rel="nofollow noreferrer">http://mywiki.wooledge.org/BashFAQ/082</a></p>
<p>See also <a href="https://mywiki.wooledge.org/BashFAQ/001" rel="nofollow noreferrer">https://mywiki.wooledge.org/BashFAQ/001</a> to learn how to read lines of input</p>
<p>The rest of your code is not even working, so here is working code based on my assumptions on what you tried to achieve:</p>
<pre class="lang-sh prettyprint-override"><code>arr2=()
while read -r crashing_pod _; do
  while IFS= read -r line; do
    arr2+=(&quot;$crashing_pod: $line&quot;)
    # arr2+=(&quot;$line&quot;)
  done &lt; &lt;(kubectl logs &quot;$crashing_pod&quot; -n namespace | tail -10)
  # arr2+=('' &quot;end of $crashing_pod 's logs&quot; '')
done &lt; &lt;(kubectl get po -n namespace | grep CrashLoopBackOff)

printf %s\\n &quot;${arr2[@]}&quot;
</code></pre>
<p>You'll see I have prepended each line with the pod name, but you can use the two commented  outlines instead if you'd rather have a separator like requested.</p>
