Reputation: 1
I have 120 pairs of files I would like to concatenate. I have the list of pair of files and the proposed merged file name in a tab delimited file as follows
Filelist.txt
/filepath/1_first.fasta /filepath/1_second.fasta > /filepath/1_merged.fasta
/filepath/2_first.fasta /filepath/2_second.fasta > /filepath/2_merged.fasta
/filepath/3_first.fasta /filepath/3_second.fasta > /filepath/3_merged.fasta
/filepath/4_first.fasta /filepath/4_second.fasta > /filepath/4_merged.fasta
I was trying:
$cat Filelist.txt | perl -ne 'chomp;system("cat $_;")'
with the idea of handling the Filelist.txt line by line and using the cat command on the line which for the first line should be...
/filepath/1_first.fasta /filepath/1_second.fasta > /filepath/1_merged.fasta
If I just have one pair and a single line in the Filelist.txt it works fine but with multiple lines I just get ..
/filepath/2_first.fasta: No such file or directory
$
Any clues why this might not be working for every single line? Or an alternative way to do this?
Thanks
Upvotes: 0
Views: 467
Reputation: 62389
I would suggest this:
sed -e 's/^/cat /' Filelist.txt | bash
Assuming your Filelist.txt
is really formatted that way (i.e. actually has the redirection included as shown). Maybe try the above without the | bash
part first and inspect the output to make sure it looks like the right commands you want to run.
Upvotes: 1
Reputation: 3753
Try this:
cat * > merged_file
This will CAT all files in the directory and the output will be outputted into the merged_file.
Upvotes: 0