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.
example:
ls
Random1_fa Random2_fa Random3_fa
inside these dirs there are different files that I want to search for only one of each:
cd Random1_fa
Random1.fa
Random1.fastq
Random1_match_genome.fa
Random1_unmatch_genome.fa
...
I want to "find" only the files with "filename".fa e.g:
/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
I did:
ls | sed 's/_fa//' |find -name "*.fa"
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:
ls| sed 's/_fa//' |find -name "$1.fa"
or
ls| sed 's/_fa/.fa/' |find -name "$1"