News for hackers. Stuff that matters.
Re:GNU ed 1.15 by ktm5j on Friday January 04, 2019 @11:03AM (#18824949)
sed is easier! You can do it with a oneliner:

`sed -i '398d' ~/.ssh/known_hosts`

I do this all the time. In fact I have a function in my .bashrc for this at work since I use it so much:

`function sedkey() { sed -i "${1}d" ~/.ssh/known_hosts }`

so I can run `sedkey 123` etc. Just another way to skin a cat I suppose.

Re:GNU ed 1.15 by firethief on Friday January 04, 2019 @12:57PM (#18826088)
The sed version is more keystrokes. Is ENTER so much more costly?
Re:GNU ed 1.15 by ktm5j on Friday January 04, 2019 @02:45PM (#18827052)
More keystrokes, but fewer lines of terminal output. Why have 5 lines of output when I don't want any?

  ktm5j@kurma /pool/share/pkgs $ ed ~/.ssh/known_hosts 
  130923
  398d
  wq
  130755
Sed just quietly does what I want. Like I said, just another way to skin a cat, do whatever works for you.
Re:GNU ed 1.15 by lokedhs on Saturday January 05, 2019 @02:27AM (#18830464)
You can use the -s flag to avoid two of those lines of ed output.
Re:GNU ed 1.15 by YaxelPerez on Friday January 04, 2019 @02:03PM (#18826705)
You can put the sed version in a cron job
Re:GNU ed 1.15 by falcor84 on Friday January 04, 2019 @02:38PM (#18827011)
I suppose that's not what you meant, but I cannot stop thinking of the poor sysadmin whose files keep getting unexpectedly trimmed to exactly 397 lines.

Also, btw, you can absolutely use ed in scripts [0], but this is also something that I would pity the maintainer of.

[0] https://www.ibm.com/developerworks/community/blogs/brian/ent...