0

This question already has an answer here:

I have this text in /etc/bash.bashrc:

alias dwa='bash /opt/dwa.sh'

I tried to delete it with the following (and similar commands):

sed -i 'alias dwa=\'bash /opt/dwa.sh\'/d' /etc/bash.bashrc

Why did my sed operation fail?

marked as duplicate by don_crissti, John1024, Stephen Rauch, Sparhawk, Jeff Schaller Dec 2 '17 at 4:25

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.

  • 1
    You can't escape anything in single quotes. – n.caillou Dec 1 '17 at 20:28
1

Why search and replace when you can delete?

sed --in-place '/^alias dwa=/d' /path/to/file
-2
awk '!/alias dwa/{print $0}' filename
  • 3
    That's not editing in place, and the {print $0} is wholly unnecessary – n.caillou Dec 1 '17 at 20:50

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