<p>Actually I am trying to make the following command in one command</p>

<pre><code>kubectl get pods| grep -oP 'mag[^\s]+'

output
mag121111
</code></pre>

<p>After that I will run the following command</p>

<pre><code>kubectl exec -itmag121111 bash
</code></pre>

<p>Now I am trying as following </p>

<pre><code> kubectl get pods| grep -oP 'mag[^\s]+' | kubectl exec -it bash
</code></pre>

mkHun
<p>This works for me</p>

<pre><code>kubectl exec -it $(kubectl get pods| grep -oP 'mag[^\s]+') --container magname -- /bin/bash
</code></pre>

<p>here magname is actual pod name</p>
