This is where Naged © lives. Naged is a way to script your way through Nagios configuration files. Basically it allows you to do things similar to what sed let's you do with text files in the context of Nagios configuration files.
The tools was written as an exercise in Ruby and so all you really need to run Naged is ruby. It has only been tested on Linux, but it uses nothing really special besides file access and standard Ruby built in functions.
To learn more about how to use Naged you can review the readme, which is also included in the distribution.
You can download the Apache licensed script here:
Then unpack the archive and run the script. The included readme will tell you how.
The archive also includes tests that I've used to validate output.