How can I loop over the output of a shell command?
<p>I want to write a script that loops through the output (array possibly?) of a shell command, <code>ps</code>.</p>
<p>Here is the command and the output:</p>
<pre><code>$ ps -ewo pid,cmd,etime | grep python | grep -v grep | grep -v sh
 3089 python /var/www/atm_securit       37:02
17116 python /var/www/atm_securit       00:01
17119 python /var/www/atm_securit       00:01
17122 python /var/www/atm_securit       00:01
17125 python /var/www/atm_securit       00:00
</code></pre>
<p>Convert it into bash script (snippet):</p>
<pre><code>for tbl in $(ps -ewo pid,cmd,etime | grep python | grep -v grep | grep -v sh)
do
   echo $tbl
done
</code></pre>
<p>But the output becomes:</p>
<pre><code>3089
python
/var/www/atm_securit
38:06
17438
python
/var/www/atm_securit
00:02
17448
python
/var/www/atm_securit
00:01
</code></pre>
<p>How do I loop through every row like in the shell output, but in a bash script?</p>