How to match filenames in different directories?(bash or python)
1
0
Entering edit mode
9.6 years ago
eyb ▴ 250

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 • 1.9k views
ADD COMMENT
1
Entering edit mode

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

ADD REPLY
1
Entering edit mode

You seem to have given up and accepted fate :)

ADD REPLY
1
Entering edit mode

At least for the moment :)

ADD REPLY
1
Entering edit mode

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.

ADD REPLY
2
Entering edit mode
9.6 years ago
Ram 43k

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.

ADD COMMENT
0
Entering edit mode

ok thx. I will look into it.

ADD REPLY

Login before adding your answer.

Traffic: 1983 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6