$ cat ip.txt
>TRINITY_DN37_c0_g1_i1 len=333 path=[361:0-43 362:44-332] [-1, 361, 362, -2]
GCCGCCATCATGGATGCCAGCCGTGTGCAGCCCATCAAGCTTGCCAGAGTCACCAAGGTT
>TRINITY_DN37_c0_g2_i1 len=356 path=[359:0-66 360:67-355] [-1, 359, 360, -2]
ACGTGACCCCCTTTCTGTCTCAAGCCGCCATCATGGATGCCAGTCGTGTGCAGCCCATCA
>TRINITY_DN15_c1_g1_i1 len=394 path=[372:0-393] [-1, 372, -2]
GCACTTACCATGCATGGAAGGCAAATGCCATCGGAAGGTCTGCAAAGACTGTTAGGGAGT
$ awk '/len=/{sub(/len=[0-9]+/,++c)} 1' ip.txt
>TRINITY_DN37_c0_g1_i1 1 path=[361:0-43 362:44-332] [-1, 361, 362, -2]
GCCGCCATCATGGATGCCAGCCGTGTGCAGCCCATCAAGCTTGCCAGAGTCACCAAGGTT
>TRINITY_DN37_c0_g2_i1 2 path=[359:0-66 360:67-355] [-1, 359, 360, -2]
ACGTGACCCCCTTTCTGTCTCAAGCCGCCATCATGGATGCCAGTCGTGTGCAGCCCATCA
>TRINITY_DN15_c1_g1_i1 3 path=[372:0-393] [-1, 372, -2]
GCACTTACCATGCATGGAAGGCAAATGCCATCGGAAGGTCTGCAAAGACTGTTAGGGAGT
-
/len=/
linhas que correspondem a esse padrão -
sub(/len=[0-9]+/,++c)
substitui a primeira ocorrência do padrãolen=[0-9]+
da linha correspondente com o valor incrementado dec
(o valor padrão é0
)
Ou com perl
perl -i -pe 's/len=\d+/++$c/e' ip.txt
a opção -i
é para edição no local