BEGIN { FS=": "; s=1; c=0 } s==1 && /^Title: / { sub("Title: ", ""); title=$0 } s==1 && /^Author: / { sub("Author: ", ""); author=$0 } s==1 && /^Created: / { sub("Created: ", ""); date=$0 } s==1 && /^State: / { sub("State: ", ""); state=$0 } s==1 && $0 == "" { printf "\n" printf "\n" printf "\n" printf " %s\n", title printf " \n" printf "\n" printf "\n" printf " \n" printf " \n", title printf " \n", author printf " \n", date printf " " printf " ", state, state printf " \n" printf "
Title%s
Author%s
Created%s
State%s
\n" printf "\n" s = 2 next } # Description s==2 && $0 == "--%--" { com_author = "" com_date = "" s = 3 c++ next } s==2 { print } # Comment header s==3 && /^From: / { sub("From: ", ""); com_author=$0 } s==3 && /^Date: / { sub("Date: ", ""); com_date=$0 } s==3 && $0 == "" { printf "\n" printf "
\n", c printf " %s on %s:
\n", c, com_author, com_date printf "\n" s = 4 next } # Comment body s==4 && $0 == "--%--" { # Close previous comment printf "
\n\n" com_author = "" com_date = "" s = 3 c++ next } s==4 { print } END { if (s == 4) { printf "\n" } printf "\n\n" printf "" printf "" # printf "title=\"%s\"\n", title; # printf "author=%s\n", author; # printf "author=%s\n", author; }