Question: Extract files with xxx_somenumber_yyyy.zzz.vcf
0
gravatar for shanika.amarasinghe
3.2 years ago by
Australia
shanika.amarasinghe30 wrote:

Hi,

I need help please... :(

I created the following code to extract .vcf files from sub directories in a directory

time find /<location path>/ -name "*.vcf"\
  | xargs cp -i --target-directory /<another location path and the directory I want to save the files in>

But now I want to modify this code to extract files which have the following format

aa_13.xxx.somenumber.yyyy.zzz.vcf

aabd_45.xxx.somenumber.yyyy.zzz.vcf

djf_65.xxx.somenumber.yyyy.zzz.vcf

fdsf_5349.xxx.somenumber.yyyy.zzz.vcf

etc...

From directories that contain 2 vcf files which have the same name but the xxx part.

e.g.

aa_13 directory has

aa_13.xxx.somenumber.yyyy.zzz.vcf and aa_13.somenumber.yyyy.zzz.vcf 

I want to get only the aa_13.xxx.somenumber.yyyy.zzz.vcf into a separate directory.

I think there is a small edition which needs to be done, reading the xxx and yyy.zzz.vcf parts... But I just can't figure it out.

Can anyone please help, or guide me to the direction I need to go?

Thanks so much in advance

 

xargs extract bash files • 2.1k views
ADD COMMENTlink modified 3.2 years ago by Ram12k • written 3.2 years ago by shanika.amarasinghe30

Hi,

This looks like an interesting problem to solve. Could you please clarify if the files are in the format:

aa_13.xxx.somenumber.yyyy.zzz

aabd_45.xxx.somenumber.yyyy.zzz

djf_65.xxx.somenumber.yyyy.zzz

fdsf_5349.xxx.somenumber.yyyy.zzz

Note that I added a .vcf to the end of the filenames. Am I correct in this assumption?

ADD REPLYlink written 3.2 years ago by Ram12k

Opps, Let me edit my question so it would be much clear.

They are in the beloe format,

aa_13.xxx.somenumber.yyyy.zzz.vcf

aabd_45.xxx.somenumber.yyyy.zzz.vcf

djf_65.xxx.somenumber.yyyy.zzz.vcf

fdsf_5349.xxx.somenumber.yyyy.zzz.vcf

etc..

Thanks for pointing that out.

ADD REPLYlink written 3.2 years ago by shanika.amarasinghe30

and *.vcf doesn't work?

Also, is your machine a Linux machine or a Mac?

Could you also give me some details on why you think it did not work (such as files were not copied etc). I think a cp -iv would give you a verbose summary of files being copied.

ADD REPLYlink modified 3.2 years ago • written 3.2 years ago by Ram12k

Oh I see...I have completely misguided you... I'm sorry.

The problem is that one directory has two .vcf files.

E.g. aa_13 directory has

aa_13.somenumber.yyyy.zzz.vcf

aa_13.xxx.somenumber.yyyy.zzz.vcf

What I want is to extract the one with the "xxx" in the middle of the file name

 

Thank you

ADD REPLYlink written 3.2 years ago by shanika.amarasinghe30
1
gravatar for Ram
3.2 years ago by
Ram12k
New York
Ram12k wrote:

From your comments, you have files such as the ones below in your aa_13 directory:

aa_13.somenumber.yyyy.zzz.vcf

aa_13.xxx.somenumber.yyyy.zzz.vcf

You'd like to pick the latter for your work.

Try this as a test run to ensure the right files are picked:

find /<location path>/ -name "*.xxx.*.vcf"

and then, if this picks the right files, modify your command so:

time find /<location path>/ -name "*.xxx.*.vcf"\
  | xargs cp -iv --target-directory /<another location path and the directory I want to save the files in>

Hope this helps!

ADD COMMENTlink written 3.2 years ago by Ram12k
1

It worked.... :) Thank you very much....

ADD REPLYlink written 3.2 years ago by shanika.amarasinghe30

You're very welcome, shanika.amarasinghe !

ADD REPLYlink written 3.2 years ago by Ram12k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1028 users visited in the last hour