Tugger the SLUGger!SLUG Mailing List Archives

Re: [SLUG] splitting text files by key word lines ?


"Voytek" <lists@xxxxxxxxxx> writes:

> # grep 'Current Database' koala
> -- Current Database: atom
> -- Current Database: commodore
> -- Current Database: digiprint
> -- Current Database: documents
> .....

Practicing my awk, try this

awk 'BEGIN { bakfile = "nodb.sql" }
        { if (/^-- Current Database:/)
                bakfile = $4 ".sql"
        }
        {
                print >bakfile
        }' < koala