如何比较头文件(fasta)的一部分并将其放入一个文件中?

how to compare a part of header file(fasta) and fit this to one file together?

我在一个目录中有更多 fasta 个文件,它们的开头相同但结尾不同:

file1abgff
-----------

file2adferr
------------

file3adfr
----------

file1adcef
-----------

如何比较目录中所有文件的开头并将匹配项放在一个新文件中 (example >file1abgffadcef)?

这段代码似乎可以解决您的问题。

假设您有输入文件:

cat input
>file1abgff
>file2adferr
>file3adfr
>file1adcef

这是我的解决方案:

 sed 's/[0-9]/& /' input | awk  '{a[]=( in a ? a[]"|" : [=11=])}END{for (i in a){print a[i]}}' | sed 's/ //' | grep  "|" | sed 's/|//'

>file1abgffadcef