Entering edit mode
5.4 years ago
Kumar
▴
170
I am looking to concatenate .fa files which are in different directories, how I can copy these files and concatenate in a single file.
It seems to be a long path as I have files in following directories.
/home/tree2/L.Genomes/L.denovo/.spades.assembly/.prokka/*fa
I just used and it works--
Thanks for you help!!
Hello,
I wanted to do a similar task and tried the following code, it worked. I wanted to concatenate 3 files with the same name but were in 3 different sub-directories.I have to repeat this for 600+ files so can you help me to put this into a loop. I'm running these in cluster environment.
Thanks!
You could do something like:
Then do:
Hi Genomax, I tried your code exactly as it is. But it gave me "no such file or directory" error. I can't copy paste my code so I just typed the code exactly how I had it.
$ ls -R
.: files test1 test2 test3
./test1: file1.FNA file2.FNA file3.FNA
./test2: file1.FNA file2.FNA file3.FNA
./test3: file1.FNA file2.FNA file3.FNA
$cd test1
$ls -1 *.FNA > ../files
$for i in
cat ./files
; do echo cat test1/$.........................................; donecat: ./files: No such file or directory
Then when I did cat files, it had my 3 files listed.
$cat files
file1.FNA
file2.FNA
file3.FNA
Is this a problem with my .FNA file format. All my files are in this format.
Of course it did. That is just an example. You need to replace your own directory/file names in the right places.
I replaced my directory names and file names :) I just used file1 etc. for easiness now. I want to send a snapshot of what I ran, but this doesn't let me attach an image.
But, I'm not sure what you meant by "files" and with what I have to replace it. to do a test run, I made 3 directories, test 1-3 and had file1.FNA, file2.FNA and file3.FNA files in those 3 directories. I also made a directory called files. IS it necessary?
Then when I did ls -R, it listed, as I showed in my above reply. (files test1 test2 test3 )
After all, when I did cat files, it listed my 3 FNA files as below, so you know I replaced my file names.
COMP100028.FNA
COMP100047.FNA
COMP100074.FNA
I see. I think the problem is you had only one dot before the name
files
which would indicate current directory.You need to have two since you put the
files
file one level up. So you should move up one level by doingcd ../
and then use the same command there.To answer your question. I just grabbed the names of the sample files into a new file called
files
. If that was confusing then replace the name with something more descriptive likemy_data_files
.Thanks!! I will try this out.