title: Bash - How to loop through sub directories and copy in a file
body: <p>I'm new to coding in bash.</p>
  
  <p>I'm trying to create something which will loop through all subdirectories, and within each one it should copy a file to that directory.</p>
  
  <p>So for example, if I have the following directories</p>
  
  <pre><code>/dir1/  
  /dir2/  
  /dir3/  
  ...  
  ...  
  /dirX/
  </code></pre>
  
  <p>And a file <code>fileToCopy.txt</code></p>
  
  <p>Then I want to run something which will open every single <code>/dirX</code> file and put <code>fileToCopy.txt</code> in that directory. Leaving me with:</p>
  
  <pre><code>/dir1/fileToCopy.txt
  /dir2/fileToCopy.txt
  /dir3/fileToCopy.txt
  ...
  ...
  /dirX/fileToCopy.txt
  </code></pre>
  
  <p>I would like to do this in a loop, as then I am going to try to modify this loop to add some more steps, as ultimately the .txt file is actually a .java file, I am wanting to copy it into each directory, compile it (with the other classes in there), and run it to gather the output.</p>
  
  <p>Thanks.</p>