title: Run shell command with variable in filename via Python
body: <p>I have files with naming convention</p>
  
  <pre><code>st009_out.abc1.dat
  st009_out.abc2.dat
  st009_out.abc3.dat 
  ..................
  ..................
  </code></pre>
  
  <p>I am writing Python code where I want to use data from the file to perform a math function and need to extract the second column from the file. I have tried it this way:</p>
  
  <pre><code>for k in range(1,10):
      file1=open('st009_out.abc'+str(k)+'.dat','r')
      ...........
      os.system("awk '{print $2}' st009_out.abc${k}.pmf &gt; raj.dat")
  </code></pre>
  
  <p>but this is not working as it is not taking the value of <code>k</code> in the shell command.</p>
  
  <p>How do I progress?</p>