<p>Basically, I need clarification if this is the right way to do: I am able to run sed command inside a container on a k8s pod. Now, the same sed I want to loop over for 10times but am not sure if this is working though I get no error from kubernetes pods or logs. Please confirm if my looping is good.</p>

<pre><code>'sed -i "s/\(training:\).*/\1 12/" ghav/default_sql.spec.txt &amp;&amp;
         lant estimate -e dlav/lat/experiment_specs/default_sql.spec.txt -r /out'
</code></pre>

<p>I want to do this working command 10times inside the same container. is the below right?</p>

<pre><code>'for run in $(seq 1 10); do sed -i "s/\(training:\).*/\1 12/" ghav/default_sql.spec.txt &amp;&amp;
         lant estimate -e dlav/lat/experiment_specs/default_sql.spec.txt -r /out; done' 
</code></pre>

<p>the pod gets created and is running fine but am not sure how to confirm my loop is good and am doing that 10times...</p>

<p>inside pod describe I see below</p>

<pre><code>Args:
  sh
  -c
  'for run in $(seq 1 10); do sed -i "s/\(training:\).*/\1 12/" ghav/default_sql.spec.txt &amp;&amp;
         lant estimate -e dlav/lat/experiment_specs/default_sql.spec.txt -r /out; done'
</code></pre>

AhmFM
<p>The &quot;<a href="https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#run-a-command-in-a-shell" rel="nofollow noreferrer">Define a Command and Arguments for a Container</a>&quot; does mention:</p>
<blockquote>
<p>To see the output of the command that ran in the container, view the logs from the Pod:</p>
<pre><code>kubectl logs command-demo
</code></pre>
</blockquote>
<p>So make sure that your command, for testing, does echo something, and check the pod logs.</p>
<pre><code>sh -c 'for run in $(seq 1 10); do echo &quot;$run&quot;; done'
</code></pre>
<p>As in:</p>
<pre><code>command: [&quot;/bin/sh&quot;]
args: [&quot;-c&quot;, &quot;for run in $(seq 1 10); do echo \&quot;$run\&quot;; done&quot;]
</code></pre>
<p>(using <code>seq</code> here, as mentioned in <a href="https://github.com/kubernetes/kubernetes/issues/56631#issuecomment-348421974" rel="nofollow noreferrer">kubernetes issue 56631</a>)</p>
<p>For any complex sequence of commands, mixing quotes, it is best to wrap that sequence in a script <em>file</em>, and call that executable file 10 tiles.
The logs will confirm that the loop is executed 10 times.</p>
