I spend most of my time building relatively large applications with Ruby, and this makes me forget how easy the quick and dirty hacks are. In less than the time it’d take me to google the right UNIX tool for escaping HTML, here is my tiny script that I use for things like blog entries and mass spam emails.
#!/usr/bin/env ruby require "cgi" puts CGI.escapeHTML(ARGF.read)
Mmh,… sweet simplicity. If you’ve not worked with the CGI lib before, there are probably other goodies in there so have a look at the API docs.
UPDATE: Sam Aaron does a good job of explaining what this script actually does in the comments