Have this file
ServerName *
ServerAlias *
ServerAlias *
<Directory>
I want to append a new line after the first occurrence of ServerAlias with the text S2. I have tried the following
sed '/ServerAlias/ a\S2\' foo
But this appends after all the occurrences.
My final result should be
ServerName *
ServerAlias *
S2
ServerAlias *
<Directory>