I have 2 files file1.seq
and file2.seq
.
They look like these:
file1.seq
ACGGTGTGATG
file2.seq
CGTGATGATGT
I want to make one fasta file which would be like:
>file1.seq
ACGGTGTGATG
>file2.seq
CGTGATGATGT
How can I do that?
With a simple for loop:
for f in file*.seq; do printf ">%s\n" "$f"; cat -- "$f"; done >newfile
for
loop runs trough all files in the directory matching file*.seq
.printf
ptints the filename.cat
prints the contents of that file.>newfile
redirecty everthing to the new file called newfile
.Or with awk
:
awk 'FNR==1{print ">"FILENAME}1' file*.seq
FNR==1
is the current record number in the file
print ">"FILENAME
print the filename with a leading >
1
in all other cases print the line.