title: Use find to identify filename same as the parent directory name
body: <p>I would like to use find in order to search for files in different subdirectories that have to match the same pattern as their parent category. </p>
  
  <p>example:</p>
  
  <pre><code>ls
  Random1_fa  Random2_fa  Random3_fa
  </code></pre>
  
  <p>inside these dirs there are different files that I want to search for only one of each:</p>
  
  <pre><code>cd Random1_fa
  Random1.fa
  Random1.fastq
  Random1_match_genome.fa
  Random1_unmatch_genome.fa
  ...
  </code></pre>
  
  <p>I want to "find" only the files with "filename".fa e.g:</p>
  
  <pre><code>/foo/bar/1_Random1/Random1_fa/Random1.fa
  /foo/bar/2_Random2/Random2_fa/Random2.fa
  /foo/bar/3_Random5/Random5_fa/Random5.fa
  /foo/bar/10_Random99/Random99_fa/Random99.fa
  </code></pre>
  
  <p>I did:</p>
  
  <pre><code>ls | sed 's/_fa//' |find -name "*.fa"
  </code></pre>
  
  <p>but not what I was looking for.
  I want to redirect the result of sed as a regex pattern in find.
  Something "awk-like" this:</p>
  
  <pre><code>ls| sed 's/_fa//' |find -name "$1.fa"
  </code></pre>
  
  <p>or</p>
  
  <pre><code>ls| sed 's/_fa/.fa/' |find -name "$1"
  </code></pre>