Skip to content

Instantly share code, notes, and snippets.

@QueuingKoala
Last active December 19, 2015 16:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save QueuingKoala/5985986 to your computer and use it in GitHub Desktop.
Save QueuingKoala/5985986 to your computer and use it in GitHub Desktop.
awk script to clean up openvpn.8 man2html output
# awk script for converting man2html openvpn output
{
# Matching lines means we skip this many
if ( match($0, "^Content-type: ") ) skip=2
if ( match($0, "Return to Main Contents") ) skip=1
# Rip out the "Updated" date as it's wrong:
if ( match($0, "^Section: ") )
sub("Updated: .*<BR>", "")
# replace localhost HREF <A> tags and their closing pair
if ( match($0, "<A HREF=\"http://localhost/.*\">") )
{
sub("<A HREF=\"http://localhost/.*\">", "")
sub("</A>", "")
}
# see if we need to skip lines. If not, print the buffer
if ( skip == 0 ) { print }
else { skip-- }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment