 <p>You could do it like this</p> <pre><code>sed -ne '/$engineinfo = engine_getinfo();/a\'$'\n''$engineinfo['engine']="asterisk";\'$'\n''$engineinfo['version']="1.6.2.11";'$'\n'';p' /var/lib/asterisk/bin/retrieve_conf </code></pre> <p>Add <code>-i</code> for modification in place once you confirm that it works.</p> <p>What does it do and how does it work?</p> <p>First we tell sed to match a line containing your string. On that matched line we then will perform an <code>a</code> command, which is "append text". </p> <p>The syntax of a sed <code>a</code> command is</p> <pre><code>a\ line of text\ another line ; </code></pre> <p>Note that the literal newlines are part of this syntax. To make it all one line (and preserve copy-paste ability) in place of literal newlines I used <code>$'\n'</code> which will tell bash or zsh to insert a real newline in place. The quoting necessary to make this work is a little complex: You have to exit single-quotes so that you can have the <code>$'\n'</code> be interpreted by bash, then you have to re-enter a single-quoted string to prevent bash from interpreting the rest of your input.</p> <p>EDIT: Updated to append both lines in one append command.</p>