Usando um script sed
:
# delete lines starting with '='
/^=/d
# handle sequence ID lines
/^SEQUENCE_ID=/{
# remove everything up to and including the '='
s///
# put the sequence ID in the hold space
h
# delete the pattern space and continue with next line
d
}
# handle primer lines
/^PRIMER.*=/{
# remove everything up to and including the '='
s///
# append a newline and the sequence ID from the hold space to the pattern space
G
# swap the two bits of the pattern space around, deleting the newline
s/^\(.*\)\n\(.*\)$/ /
}
Teste:
$ sed -f script.sed file
ID_1 ACGTGTAGCGGTTCAGACG
ID_1 ACCATGCATGATCCATCCAGG
ID_1 CACAGCCACAGCAGCACAC
ID_1 ATGCAGGTGATCAAGTTACGCC
ID_2 CACAGCCACAGCAGCACAC
ID_2 GCAGGTGATCAAGTTACGCCATT
Sem um arquivo de script separado:
$ sed -e '/^=/d' -e '/^SEQUENCE_ID=/{s///;h;d;}' -e '/^PRIMER.*=/{s///;G;s/^\(.*\)\n\(.*\)$/ /;}' file
ID_1 ACGTGTAGCGGTTCAGACG
ID_1 ACCATGCATGATCCATCCAGG
ID_1 CACAGCCACAGCAGCACAC
ID_1 ATGCAGGTGATCAAGTTACGCC
ID_2 CACAGCCACAGCAGCACAC
ID_2 GCAGGTGATCAAGTTACGCCATT
Variante mais curta:
$ sed -n -e '/^SEQUENCE_ID=/{s///;h;}' -e '/^PRIMER.*=/{s///;G;s/^\(.*\)\n\(.*\)$/ /p;}' file