This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to match filenames in different directories?(bash or python)

I have a set of files in two directories

~/Desktop/dir1 and ~/Desktop/dir2

I need to match files in dir1 to files in dir2 or vice versa

filenames in /dir1 are: 1.out, 2.out ... 21.out

filenames in /dir2 are: chr-1.out, chr-2.out ... chr-21.out

I wrote a plotting script in python which accepts command line arguments for filenames and does the plotting. So the question is how to match the files and provide it to a script? I tried to use bash, but I cant figure out how to do that. Maybe it is possible to that from python?

I could have done it by hand, but I would rather learn how to do that automatically.

unix linux python

This looks rather off-topic. Perhaps you want to edit things about to make it at least vaguely bioinformatics related...

You seem to have given up and accepted fate :)

At least for the moment :)

I do agree with Devon Ryan and I would add that even if your files were bioinformatics data this is a purely bash/os usage question and as such it is probably best suited to StackOverflow.

1 answer

So, what you're trying to do is called globbing. Check it out here

And, as Istvan Albert and Devon Ryan say, this is a CS question in a bioinformatics forum. Please search stack overflow or Google. A critical skill to all fields that involve CS/IT is knowing what keywords to use with Google (most of what you want solved in IT is solved by someone else already), and that comes with practice.

ok thx. I will look into it.

Log in to answer this question.