3 ms·
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
by ktm5j 8y ago
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.
- firethief 8y agoThe sed version is more keystrokes. Is ENTER so much more costly?
- YaxelPerez 8y agoYou can put the sed version in a cron job
- falcor84 8y agoI 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/entry/ed_editor https://www.ibm.com/developerworks/community/blogs/brian/ent...
- ktm5j 8y agoMore 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.
- lokedhs 8y agoYou can use the -s flag to avoid two of those lines of ed output.