title: Iterating through a list of commands in a file in Shell Programming
body: <p>I have a file containing a list of unix commands like "ls -la /etc/passwd". I want to iterate through this list of commands, and take appropriate action. </p>
  
  <p>Currently, my code is something like:</p>
  
  <pre><code>#!/bin/bash
  clear
  for cmds in `cat /tmp/cmd`
  do
          if [  $cmds ] ; then
                  echo $cmds;
          fi
  done
  </code></pre>
  
  <p>But, what I get is an output where the commands are broken up in different lines like</p>
  
  <pre><code>ls 
  -la 
  /etc/passwd
  ls 
  -la
  /etc/shadow
  </code></pre>
  
  <p>and not </p>
  
  <pre><code>ls -la /etc/passwd
  ls -la /etc/shadow
  </code></pre>
  
  <p>Any ideas?</p>