Advertisement
Guest User

Insert header titles

a guest
Apr 19th, 2010
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. Try:
  2.  
  3. awk '{ if ($0 ~ /<p>[ ]*[0-9]+:[0-9]+/) { match($0, /[0-9]+/); print "<h1>Chapter " substr($0, RSTART, RLENGTH) "</h1>"; print $0; } else print; }'
  4.  
  5. Invoke the above for all the files sending the output to some directory:
  6.  
  7. for fname in *.htm *.html; do
  8. awk '{ if ($0 ~ /<p>[ ]*[0-9]+:[0-9]+/) { match($0, /[0-9]+/); print "<h1>Chapter " substr($0, RSTART, RLENGTH) "</h1>"; print $0; } else print; }' "${fname}" > "output/${fname}"
  9. done
  10.  
  11. The name of the output directory name is assumed to be "output" in above.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement