mardi 4 août 2015

Can I get the length of the next line after match with sed?

I have a file of sequences, formatted as a line of information followed by the sequence, e.g.:

someinformation length=50
JJJIJJJJJJJJJIJGIJJJJJJIJJIJJJJJIJJJJHHHHHFFFFFCCC
someotherinformation length=50
GEFE?BEDHCBBACEBHAFEBFEBFHFFDDDFD@@@
[...]

I want replace the length=50 (could be a different number) with the actual length of the next line (without next line character). So something like this:

sed -i "s/length=[0-9]+/length=length_next_line/" infile

Is it possible in sed to get the length of the next line?

Aucun commentaire:

Enregistrer un commentaire