0

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?

  • 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.