fixed BSD compatibility by replacing awk for splitting template

this is a little awkward and possibly brittle - but it seems to work (at
least until someone complains)