Are there any tools to do what I want already? I'd like to split the file 'one' at lines starting with @, followed by a filename:
$ cat one
@header
-- header --
@body
-- body --
@body isn't a split point
@footer
-- footer --
$ splitit one
$ ls
body footer header one
$ cat header
-- header --
$ cat body
-- body --
@body isn't a split point
$ cat footer
-- footer --
What is splitit?
Use case:
awk 'NF==1 && sub(/^@/,""){f=$0; next} {print > f}' one
If you will have many output files and don't use GNU awk then you'll have to close them as you go:
awk 'NF==1 && sub(/^@/,""){close(f); f=$0; next} {print > f}' one