#!/usr/bin/awk -f /{/ { match($0, /^[[:alnum:]_]+/) fname = substr($0, RSTART, RLENGTH) } { if (fname) { print >fname } } /}/ { fname = "" }