<p>I have the following code</p>
<pre><code>#/bin/bash
set -e
set -x

requestResponse=$(ssh jump.gcp.xxxxxxx &quot;&quot;&quot;source dev2 spi-dev
kubectl get pods -o json | jq '.items[] |select(.metadata.name[0:3]==&quot;fea&quot;)'  | jq .status.podIP
2&gt;&amp;1&quot;&quot;&quot;)
echo $requestResponse
</code></pre>
<p>In the above code <code>source dev2 spi-dev</code> means we have moved to spi-dev namespace inside dev2 cluster. <code>kubectl get pods -o json | jq '.items[] |select(.metadata.name[0:3]==&quot;fea&quot;)'  | jq .status.podIP 2&gt;&amp;1&quot;&quot;&quot;) </code> means to print ip address of pod starting with fea. If I do manually kubectl command works. I have also tried escaping fea like <code>\&quot;fea\&quot;</code></p>

Sriram Chowdary
<p>These triple quotes <code>&quot;&quot;&quot;</code> are not working as you expect.
Try to change it like this:</p>
<pre><code>ssh jump.gcp.xxxxxxx &lt;&lt; EOF
source dev2 spi-dev
kubectl get pods -o json             | \
jq '.items[]                         | \
select(.metadata.name[0:3]==&quot;fea&quot;)'  | \
jq .status.podIP 2&gt;&amp;1
EOF
</code></pre>
