1,$g/foo/p
.=
