<p>I have a script to extract the logs of crushed pods, but i want also to give as a parameter the pod names (In case I need also the logs from other pods, not just crushed ones). My script looks like this:</p>
<pre><code>#!/bin/bash

y=1;
for pod in &quot;$@&quot;
do
        echo &quot;Pod name: $y: $pod&quot;;
        y=$((y + 1));
done

CrashLoopBackOff=`for i in $(kubectl get po -n namespace |grep CrashLoopBackOff | awk '{print $1}'); do echo $i; done`

echo &quot;Pods in CrashLoopBackOff: &quot;
echo
echo ======= $CrashLoopBackOff ==========
echo
arr2=()
while read -r CrashLoopBackOff _; do
  while IFS= read -r line; do
    arr2+=(&quot;$CrashLoopBackOff: $line&quot;)
  done &lt; &lt;(kubectl logs &quot;$CrashLoopBackOff&quot; -n namespace| tail -10)
done &lt; &lt;(kubectl get po -n namespace| grep CrashLoopBackOff)

printf %s\\n &quot;${arr2[@]}&quot;
</code></pre>
<p>But seems that if I pass the pods name as arguments, the output is just for the crushed pod. I don't have so much experience with scripting and I got stuck here, any help is appreciated.
Thank you</p>

Sissi_00_20
<p>You can add this at the end of the file:</p>
<pre><code>for pod in $@
do
  echo &quot;Printing logs for requested pod $pod&quot;
  kubectl logs -n namespace $pod | tail -n 10
done
</code></pre>
<p>Hope that helps to progress your script</p>
