1

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?

0

1 Answer 1

1

With a simple for loop:

for f in file*.seq; do printf ">%s\n" "$f"; cat -- "$f"; done >newfile
  • The for loop runs trough all files in the directory matching file*.seq.
  • printf ptints the filename.
  • and 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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .