Let's say I have to perform these actions from an input file:
extract nth field from a line starting with a given pattern (in the exemple: 2nd field of the line starting with pattern 'name')
print the field content at the beginning of every following line, while the line does not start with the selected pattern
when a new line matching the pattern is found, repeat step 1 and 2
I'm currently doing this using Python, but it would be better using something light and fast from command line (like awk, for exemple).
name NAME_A inf field_A1 name NAME_B inf field_B1 inf field_B2
name NAME_A NAME_A inf field_A1 name NAME_B NAME_B inf field_B1 NAME_B inf field_B2