Article 5DWTY Remove a line from a file (including newline)

Remove a line from a file (including newline)

by
iicapn
from LinuxQuestions.org on (#5DWTY)
Hi,

I'm trying to remove a line from /etc/passwd

Something like this:
sed -i "s|^admin:.*||" /etc/passwd

Which works... but it leaves an unsightly gap in the file. I know sed is probably not the best tool for this, and I've googled and tried all sorts of things with awk, perl, and tr but I can't quite seem to put my finger on it.

Is there an elegant way to remove a line from a text file with regex and include the \n at the end?

Thanks in advance!latest?d=yIl2AUoC8zA latest?i=HZSixAYJuJk:DNpUiSCjxFw:F7zBnMy latest?i=HZSixAYJuJk:DNpUiSCjxFw:V_sGLiP latest?d=qj6IDK7rITs latest?i=HZSixAYJuJk:DNpUiSCjxFw:gIN9vFwHZSixAYJuJk
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments