One of the eldest Unix utilities is the stream editor Sed. It was born 1973, and is still going strong. If you haven't yet made its acquaintance, I highly recommend that you read Bruce Barnett's Sed -- An Introduction and Tutorial. I use the GNU version of Sed almost everyday.
There is just one problem with Sed. It sometimes get confused by character encoding, in particular UTF-8 and ISO-8859-1