AWK: Split html headers and content

Simple parser for curl’s output to split html file to headers and content files.

Usage: $ curl -i -o /tmp/splitit.html http://ya.ru $ ./htmlsplit.awk /tmp/splitit.html $ ls -1 /tmp/splitit.html* /tmp/splitit.html /tmp/splitit.html.head /tmp/splitit.html.content
Here is the source: $ cat htmlsplit.awk #!/bin/awk -f # vim: ts=4 sw=4 BEGIN{ ISHEAD=1; } { if (1==ISHEAD) { if (/^\r?$/) { ISHEAD=0; } else { print >(ARGV[1]".head") } } else { print >(ARGV[1]".content") } }

Leave a Reply

Your email address will not be published. Required fields are marked *