<pre><code>apiVersion: v1
data:
  backupscript:
  service.properties: |
    agent.download.location = /home/bnr
    script.execution.time.in.minutes = 1
</code></pre>
<p>Need to fetch value in &quot;script.execution.time.in.minutes&quot;.</p>
<p>I am using ..-o &quot;jsonpath={.data['service\.properties'].'script\.execution\.time\.in\.minutes'}&quot;</p>
<p>It is giving me empty result.
How do we use the Escape on the end field's filter.</p>

Ankit Sharma
<p>Sometimes I find it helpful when working with jsonpath expressions, to start smaller and build up.</p>
<p>For example, does this work and if so, what does it return?</p>
<pre><code>-o &quot;jsonpath={.data['service\.properties']&quot;
</code></pre>
<p>Then add the next part on.</p>
<p>That being said, I think the problem you're going to run into is that these are not yaml properties, but instead is a string, as indicated by the <code>|</code>:</p>
<pre><code>  service.properties: |
    agent.download.location = /home/bnr
    script.execution.time.in.minutes = 1
</code></pre>
<p>So I don't think you're going to be able to use jsonpath alone to query the value of <code>script.execution.time.in.minutes</code>.</p>
<p>You can probably do what you want with a combination of jsonpath and awk+sed, something like this:</p>
<pre><code>kubectl get pod foo -o jsonpath=&quot;{.data['service\.properties']}&quot; | awk -F'=' '$1 ~ /script\.execution\.time\.in\.minutes/ {print $2}' | sed 's/ //'
</code></pre>
<p>This does the following:</p>
<ol>
<li>Get the service properties using jsonpath</li>
<li>Use awk to extract the number from the line that has script.execution.time.in.minutes</li>
<li>Use sed to remove spaces</li>
</ol>
<p>There might be a more elegant way to accomplish this, but hopefully this can at least help you get an idea of one way to do it.</p>
