This is a test version of Biostars. For the public version, visit https://www.biostars.org.
print file name having particular extension located in numerous subdirectory

Hello!

I want to print the name of file having '.gbk' extension located in numerous subdirectory within my directory 'test'. However I have an issue with my bash code

#!/bin/bash
files='$.gbk'
if [ "-e home/ha/desktop/test/*/$files" ];
then
echo "$files"
fi

any suggestions?

bash

Hello abel.i!

This is a not a bioinformatics question and a valid solution has been found by OP.

For this reason we have closed your question. This allows us to keep the site focused on the topics that the community can help with.

If you disagree please tell us why in a reply below, we'll be happy to talk about it.

Cheers!

3 answers

Something like :

find pathDirectoryWhereYouWantStart -type f -iname "*.gbk"

man find

Thanks!!

it works with:

ls -I "*.gbk" -R

While that may sort of work, it is an ugly way to find the files you need (especially if there are files other than .gbk in the directories). Look into find as suggested by @titus above.

Yes, I'm looking for an elegant way to do it!

For the moment this is what I found:

find . '(' -name '*.gbk' ')' > FileWithGBK

Log in to answer this question.