Gaia's Stepdaughters

Psych Profile: Conservationist

A small tip to clean up your template.

E-mail this post

Remember me (?)

All personal information that you provide here will be governed by the Privacy Policy of More...

The blogger template I use (Rounder) has a lot of spaces, tabs and newlines in its source. The ugly formatting has been bothering me since the time I decided to modify the code, inorder to add Haloscan trackback, Sitemeter and other stuff to the sidebar.
Its actually easy to start cleaning up your code using tr and sed.

Linux: cat deidre.tmpl | tr -s "\t" | tr -s "\n".
: cat deidre.tmpl | sed "s/\r\n/\n/g" | tr -s "\n" | tr -s "\t".

The tr utility translates a character to another. In this case "-s" tells it to squeeze its parameter, therefore tr -s "\n" will replace all consecutive newlines with a single newline.

The extra sed step is necessary in cygwin because Dos/Windows uses an ASCII carriage return (^M or \r) and then a line feed (^J or \n) at the end of each line, while unix/linux uses only the line feed character.

0 Responses to “A small tip to clean up your template.”

Leave a Reply

      Convert to boldConvert to italicConvert to link


About me

  • I'm Lady Deidre
  • From London, United Kingdom
  • I'm a struggling journalist, with an interest in web design.
  • My profile

Previous posts



ATOM 0.3