Iniciando uma nova linha baseada em uma string específica

1

Eu preciso iniciar uma nova linha com base em uma string específica e adicionar as linhas entre essas strings na mesma linha.

Entrada:

Gator_locus100 

AGTCGTGTAGATGATAGTCGATGATGGATGANNNNGTACGT
GCTCAGTCGTGCTCGTCGATCGATCGTCAGCTCGATCGATCGATCGATCGACTCGATCG
GCTCGATCGATCGATC

Gator_locus101

ATCGATCGATCGATCGATCGATCGATCGATCGAT
GCAGTCGATCGATACGATCGATACGACTACGA
TCGATCGATCGCATCGATCGATCGACTC

Gator_locus102
NNNNNNNNNGCTCAGTCGATCGATCGCATCGATCGACTACGTACGATCGATCAGCATCAG
GCTCAGTCGTGCTCGTCGATCGATCGTCAGCTCGATCGATCGATCGATCGACTCGATCG
GACTCAGATCGATGACTACGATCAGATCGATAACGATCAGTACGACTACGATCAGCATCAGAT
NNNNNNNNNNNNNNNNNNNNNGACTACGACATCGATCAGACTCAGACGT

Ouput:

Gator_locus100  AGTCGTGTAGATGATAGTCGATGATGGATGANNNNGTACGTGCTCAGTC....

Gator_locus101 ATCGATCGATCGATCGATCGCGATGCAGTCGATCGATACGATCGATACG....

Gator_locus102 NNNNNNNNNGCTCAGTCGATCGATCGCATCGATCGACTACGTACGATC .....

Como fazer isso?

    
por Josh 13.03.2018 / 15:56

1 resposta

1

awk solução:

awk -v ORS= '/Gator_/{ if (NR > 1) print RS RS }1; END{ print RS }' file

A saída:

Gator_locus100 AGTCGTGTAGATGATAGTCGATGATGGATGANNNNGTACGTGCTCAGTCGTGCTCGTCGATCGATCGTCAGCTCGATCGATCGATCGATCGACTCGATCGGCTCGATCGATCGATC

Gator_locus101ATCGATCGATCGATCGATCGATCGATCGATCGATGCAGTCGATCGATACGATCGATACGACTACGATCGATCGATCGCATCGATCGATCGACTC

Gator_locus102NNNNNNNNNGCTCAGTCGATCGATCGCATCGATCGACTACGTACGATCGATCAGCATCAGGCTCAGTCGTGCTCGTCGATCGATCGTCAGCTCGATCGATCGATCGATCGACTCGATCGGACTCAGATCGATGACTACGATCAGATCGATAACGATCAGTACGACTACGATCAGCATCAGATNNNNNNNNNNNNNNNNNNNNNGACTACGACATCGATCAGACTCAGACGT
    
por 13.03.2018 / 16:07