title: run a script in multiple folders in bash
body: <p>I have a folder Cabo_Verde, and inside this folder I have several folders (001 to 300) with several files each, like this:</p>
  
  <p>Filename: Cabo_verde</p>
  
  <pre><code>     001
       2008.001.00.00.CVBR1.LHZ.SAC
       2008.001.00.00.CVBR2.LHZ.SAC
       ...
  
       002
       2008.002.00.00.CVBR1.LHZ.SAC
       2008.002.00.00.CVBR2.LHZ.SAC
       ...
  </code></pre>
  
  <p>I want to run a script in each folder and this is what I did:</p>
  
  <pre><code>for dir in `ls $Cabo_verde`;
  do
     for subdir in `ls $Cabo_Verde/$dir`;
     do
        $(for file in *SAC; do
  sac &lt;&lt;EOF
  echo on
  read $file
  chnhdr KCMPNM LHZ
  write over
  quit
  EOF
  done)
  done;
  done
  </code></pre>
  
  <p>In the end I got </p>
  
  <pre><code>ls:cannot access /001: No such file or directory
  ls:cannot access /002: No such file or directory
  </code></pre>
  
  <p>Can anyone help me please?</p>
  
  <p>Thanks</p>