This question already has an answer here:

I added a row to a document with a cat heredocument

cat <<-'DEFINE' >> ./wp-config.php
define( 'DISALLOW_FILE_EDIT', true );

I later wanted to remove it and did:

sed -i "s/define( 'DISALLOW_FILE_EDIT', true );//g" ./wp-config.php

After removing it, I noticed an extra empty line where the code was - This is indeed the natural thing to happen - sed just deleted the code, not the whole row.

My question is, can I use sed to actually remove the whole row, and not just the code inside it?

marked as duplicate by Patrick, don_crissti, phk, Jeff Schaller, Kusalananda May 17 '17 at 14:18

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


The empty line comes from you substituting the text with nothing.

Instead of using a substitution (s), use a deletion (d):

sed -i "/define( 'DISALLOW_FILE_EDIT', true );/d" ./wp-config.php

Not the answer you're looking for? Browse other questions tagged or ask your own question.