jeudi 23 juillet 2015

Replacing pattern with pattern+incrementing number

Here is a snippet of the text files I want to edit:

"> RECORD:W7_S7_L001_R2_001_43549049:wang1141_Nem_0425_6 AGGCTCGAACTTCCTTTGGATGAACTCCAAAAGTCCCTCTAAGAAGTTAACACCTTACAA

"> RECORD:W41_S41_L001_R2_001_36873913:wang1141_Nem_0425_6 TGCCTCAAACTTCCGTGGATTAAACATCCACAGTCCCTCTAAGAAGTTAGCCGTCAACCAA

"> RECORD:W32_S56_L001_R2_001_29095773:wang1141_Nem_0425_6 TGCCTCAAACTTCCTTATGCTTGCACATAAAGTCCCTCTAAGAAGTTAGACTCCCTATTTA

Now I want to replace every ">" with ">$a" and then incrementing "$a++". I found a solution that almost worked:

awk '/>/{sub(/start/,++n);{print}'

But this only replaces the > with a number without the >.

I appreciate every help!

Aucun commentaire:

Enregistrer un commentaire