Is there a way to prevent sed from adding carriage return (^M)?
<p>I am trying to add <code>define('WP_MEMORY_LIMIT', '96M');</code> after the <code>define('WP_DEBUG', false);</code> in a wordpress php file.</p>

<p>Here is what I tried so far:</p>

<p>1-</p>

<pre><code>sed -b -i "/'WP_DEBUG', false);/a define('WP_MEMORY_LIMIT', '96M');" $full_path/wp-config.php;
</code></pre>

<p>2- </p>

<pre><code> sed -i "s/'WP_DEBUG', false);/'WP_DEBUG', false);\ndefine('WP_MEMORY_LIMIT', '96M');/" $full_path/wp-config.php;
</code></pre>

<p>The problem with that, all the new lines being replaced with this carriage return char. How can I add a new line after a specific line and do not have this issue ?</p>

<pre><code>define('WP_DEBUG', false);^M
define('WP_MEMORY_LIMIT', '96M');
</code></pre>

<p>Using sed (GNU sed) 4.2.2, Ubuntu 16.04</p>

<p>Here is the screenshots for clarify the issue:</p>

<p><a href="https://i.stack.imgur.com/VsqnI.png" rel="noreferrer"><img src="https://i.stack.imgur.com/VsqnI.png" alt="enter image description here"></a></p>

<p><a href="https://i.stack.imgur.com/RYUcb.png" rel="noreferrer"><img src="https://i.stack.imgur.com/RYUcb.png" alt="enter image description here"></a></p>

<p><strong>NOTE:</strong>
Okey, problem is solved after reading @anishsane's answer. Since the original file (from wordpress.org/latest.zip) has CRLF (windows) line endings, adding \n was breaking the file view. Using "\r\n" solved the issue:</p>

<pre><code>sed -i "s/'WP_DEBUG', false);/'WP_DEBUG', false);\r\ndefine('WP_MEMORY_LIMIT', '96M');/" $full_path/wp-config.php;
</code></pre>

<p>I am not sure why the downvotes. Please explain, so I can clarify the question.</p>