Answers.Body: <p>Tinkered a bit and realized the solution did not neccistate a for loop.</p>
  <pre><code>mkdir ~/ST_0075/alignment; cp ~/ST_0075/annotations/*/*.gff ~/ST_0075/alignment
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-07-12T16:59:21.340Z
Answers.Text: Exactly, and thanks for posting an answer! Note that if you're using bash, you can make it even simpler if you enable `globstar`. You can do: `shopt -s globstar; cp ~/ST_0075/annotations/**/*.gff ~/ST_0075/alignment` and that will recurse an arbitrary number of directories under `annotations`, so you don't need to count the exact number of `*/` you need.
Answers.UserDisplayName: terdon
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-07-12T17:52:10.323Z
Answers.Text: Hi @terdon, is it `**` that is doing the trick?
Answers.UserDisplayName: haci
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-07-12T17:56:49.480Z
Answers.Text: Yes, try `man bash | grep -A3 'globstar$'` to see the details.
Answers.UserDisplayName: terdon
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-07-12T16:12:29.480Z
Answers.LastActivityDate: 2021-07-12T16:12:29.480Z
Answers.UserDisplayName: MicroBiostat
Body: <p>I have multiple .GFF files, each in a single directory per annotated whole genome, that I wish to copy into a single directory so that I can perform a core genome alignment.</p>
  <p>However the following code does not seem to work:</p>
  <pre><code>for pathname in &quot;~/ST_0075/annotations/*/*.gff&quot;; do cp &quot;$pathname&quot; ~/ST_0075/alignment; done
  </code></pre>
  <p>The directory structure is the following:</p>
  <pre><code>Home
  -ST_0075
  ---Annotations
  -----Sample_001
  ----------001.gff
  </code></pre>
  <p>The goal is to copy from multiple Sample_XXX subdirectories within <code>Annotations</code> the XXX.gff files into another directory named <code>alignment</code></p>
  
Tags: <linux><data-management>
Title: Copying files from multiple directories to a single
ThreadText: # Copying files from multiple directories to a single
  
  (Asked by: username_0 on 2021-07-12)
  
  I have multiple .GFF files, each in a single directory per annotated whole genome, that I wish to copy into a single directory so that I can perform a core genome alignment.
  
  However the following code does not seem to work:
  
  ```
  for pathname in "~/ST_0075/annotations/*/*.gff"; do cp "$pathname" ~/ST_0075/alignment; done
  
  ```
  
  The directory structure is the following:
  
  ```
  Home
  -ST_0075
  ---Annotations
  -----Sample_001
  ----------001.gff
  
  ```
  
  The goal is to copy from multiple Sample\_XXX subdirectories within `Annotations` the XXX.gff files into another directory named `alignment`
  
  **Tags:** linux, data-management
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2021-07-12. Score: 3
  
  Tinkered a bit and realized the solution did not neccistate a for loop.
  
  ```
  mkdir ~/ST_0075/alignment; cp ~/ST_0075/annotations/*/*.gff ~/ST_0075/alignment
  
  ```
  
  > **Comments:**
  > **username_1**: Exactly, and thanks for posting an answer! Note that if you're using bash, you can make it even simpler if you enable `globstar`. You can do: `shopt -s globstar; cp ~/ST_0075/annotations/**/*.gff ~/ST_0075/alignment` and that will recurse an arbitrary number of directories under `annotations`, so you don't need to count the exact number of `*/` you need.  
  > **username_2**: Hi @username_1, is it `**` that is doing the trick?  
  > **username_1**: Yes, try `man bash | grep -A3 'globstar$'` to see the details.  
  
  ---
  
  