I'm trying to use sed for updating a commented config file. Rather than tacking everything at the EOF, I'm trying to keep things sectioned off. My config looks something like this.
# SECTION ONE data... data... data... <insert line here> # SECTION TWO data... data...
I'm trying to insert lines at the end of section one, but I'm having a hard time writing a search pattern since it won't allow "\n" and you can't have multiple "^$" in a pattern. I'd like something like the following:
sed -i "/^\n\n# SECTION TWO.*/i data..." somefile.conf or sed -i "/^$^$# SECTION TWO.*/i data..." somefile.conf
I'm open to other suggestions as well, but I'd like to keep it to a single line if possible. This is part of a much larger script. I know this is pretty easy with Python, Perl, etc., but I'm trying to keep this to a "shell" solution.