title: Shell script to nohup every file in a directory
body: <p>This is a follow up to the questions posted here <a href="https://stackoverflow.com/q/14202947/1516064">Shell script to execute nohup against an inputed filename</a>.</p>
  <p>I am just trying to find away to modify the no_hup script below to execute against a whole directory of SQL scripts as opposed to just a single file.  So I am trying to find a good way to modify the below script to excute against a whole directory of files:</p>
  <blockquote>
  <p>How do I write a shell script so that I can run against a directory called test that contains the files foo1.sql, foo2.sql, foo3.sql</p>
  <p>./nohup_sh test</p>
  <p>which will produce the ouput</p>
  <p>nohup psql -d db -f test/foo1.sql &gt;&amp; test/foo1.out &amp;</p>
  <p>nohup psql -d db -f test/foo2.sql &gt;&amp; test/foo2.out &amp;</p>
  <p>nohup psql -d db -f test/foo3.sql &gt;&amp; test/foo3.out &amp;</p>
  </blockquote>
  <p>This is the code I have been using from the previous answer called nohup_sh</p>
  <pre><code>#!/bin/bash
  
  outputFile=&quot;$(echo $1 | cut -d\. -f 1).out&quot;
  
  nohup psql -d db -f &quot;$1&quot; &gt;&amp; &quot;$outputFile&quot; &amp;
  </code></pre>