|
|
|
|
|
by swa14
5110 days ago
|
|
Even today 'ed' has practical uses apart from being the default emergency backup of the backup editor. One situation where I always use 'ed' is when I reinstall a machine (with the same ip) and ssh tells me the keys don't match together with the line number in the file known_hosts.
It's easy as:
#ed ~/.ssh/known_hosts
15d
wq (assuming the mismatching line was 15). Only sed would be faster if it wasn't for the time spent always looking up the "-i" (edit in place) flag, so I just use ed. Also knowing a little 'ed' will make working with 'vi' easier, assuming 'vi' is not your usual editor. |
|
More relevant is that I already know a bunch of tools for doing deletion of line 5. For example: perl -i -ne 'print unless $.==15' . It's more complicated, but it's a smaller number of tools for me to remember.
Actually, I probably would have used mv to a temp file + awk 'NR!=15' + rm temp file. Even knowing perl and python I still use awk pretty often, and it comes to mind much easier than thinking about ed or sed. Plus, I still have the temp file around in case I need to revert a mistake, like if I accidentally typed '51' instead of '15'.