Some gsed magic to insert a line below the regex matched text
So I'm working on finishing automating as much of my install fresh installations of Crowd, Confluence and JIRA. One of the things I was looking for is how to use gsed to insert some thing after a specific line has been matched with regex. For example if I insert a line before something I used something.
Before I started testing I created a test text file:
[jacques@auriga ~]$ cat far hello ABOVE BELOW ayoba
Then I wanted to insert the word testing above the word ABOVE:
[jacques@auriga ~]$ gsed -i"" -e "/ABOVE/i\ testing" far [jacques@auriga ~]$ cat far hello testing ABOVE BELOW ayoba
So that works well - after quite a bit of fiddling it was discovered to insert a line after something I needed to change the i script modifier to an a:
[jacques@auriga ~]$ gsed -i"" -e "/BELOW/a\ testing" far [jacques@auriga ~]$ cat far hello testing ABOVE BELOW testing ayoba

