I have a complicated file, which looks like this :
configuration {
step 58000
dt 2.00000000000000e+00
}
colvar {
name r
x 1.44869849559022e+01
}
0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00
0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00
hill {
step 1440
weight 1.00000000000000e-01
centers 1.47455750990065e+01 -1.69229380745887e+02
widths 1.25331413731550e+00 1.25331413731550e+00
}
hill {
step 1560
weight 1.00000000000000e-01
centers 1.47435719215456e+01 -1.70289673373179e+02
widths 1.25331413731550e+00 1.25331413731550e+00
}
hill {
step 1680
weight 1.00000000000000e-01
centers 1.47427376221419e+01 -1.68774767870364e+02
widths 1.25331413731550e+00 1.25331413731550e+00
}
I am interested in extracting steps, weight and widths from this file and writing them in a new output file with a tab separation. Just like this :-
#!step width1 width2 weight
1440 1.25331413731550e+00 1.25331413731550e+00 1.00000000000000e-01
I have the following, which only writes steps and weight :-
awk ' b ~ /hill/ && a ~ /step/ && /weight/ {print v"\t"$2}{b=a; a=$0; v=$2}' input > output
How can I extend it to write widths as well ?