It worked :) Thank you very much
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
...
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
1 answer
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!
You're very welcome, shanika.amarasinghe!
Log in to answer this question.
Hi,
This looks like an interesting problem to solve. Could you please clarify if the files are in the format:
Note that I added a
.vcfto the end of the filenames. Am I correct in this assumption?Oops, Let me edit my question so it would be much clear.
They are in the below format,
etc..
Thanks for pointing that out.
and
*.vcfdoesn'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 -ivwould give you a verbose summary of files being copied.Oh I see...I have completely misguided you... I'm sorry.
The problem is that one directory has two .vcf files.
E.g.
aa_13directory hasWhat I want is to extract the one with the
xxxin the middle of the file nameThank you