The sed version is more keystrokes. Is ENTER so much more costly?
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.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
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...
`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.