I am trying to add define('WP_MEMORY_LIMIT', '96M');
after the define('WP_DEBUG', false);
in a wordpress php file.
Here is what I tried so far:
1-
sed -b -i "/'WP_DEBUG', false);/a define('WP_MEMORY_LIMIT', '96M');" $full_path/wp-config.php;
2-
sed -i "s/'WP_DEBUG', false);/'WP_DEBUG', false);\ndefine('WP_MEMORY_LIMIT', '96M');/" $full_path/wp-config.php;
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 ?
define('WP_DEBUG', false);^M
define('WP_MEMORY_LIMIT', '96M');
Using sed (GNU sed) 4.2.2, Ubuntu 16.04
Here is the screenshots for clarify the issue:
NOTE: 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:
sed -i "s/'WP_DEBUG', false);/'WP_DEBUG', false);\r\ndefine('WP_MEMORY_LIMIT', '96M');/" $full_path/wp-config.php;
I am not sure why the downvotes. Please explain, so I can clarify the question.