<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>

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