<p>I am trying to extract podname using the below jq query.</p>
<pre class="lang-sh prettyprint-override"><code>❯ kubectl get pods -l app=mssql-primary --output jsonpath='{.items[0].metadata.name}'
mssqlag-primary-deployment-77b8974bb9-dbltl%                                                                                                                                                                                                                              
❯ kubectl get pods -l app=mssql-primary -o json | jq -r '.items[0].metadata.name'
mssqlag-primary-deployment-77b8974bb9-dbltl
</code></pre>
<p>While they both provide the same out put the first one has a % character at the end of the pod name. Any reason why ? Is there something wrong with the jsonpath representation in the first command ?</p>

Pradeepl
<p>I'm guessing <code>zsh</code> is your shell. The <code>%</code> is an indicator output by your shell to say that the last line output by <code>kubectl</code> had no newline character at the end. So it's not <em>extra</em> output, it's actually an indicator that the raw <code>kubectl</code> command outputs <em>less</em> than <code>jq</code>.</p>
<p>You could explicitly add a newline to the jsonpath output if you want it:</p>
<pre><code>kubectl get pods -l app=mssql-primary --output jsonpath='{.items[0].metadata.name}{&quot;\n&quot;}'
</code></pre>
<p>Or in the other direction you could tell <code>jq</code> not to add newlines at all by specifying <code>-j</code> instead of <code>-r</code>:</p>
<pre><code>kubectl get pods -l app=mssql-primary -o json | jq -j '.items[0].metadata.name'
</code></pre>
