Tag Archives: sed

sed -Ee

Just quickly writing this down: Not sure why it isn’t on sed(1) but from now on I’ll be using sed -Ee ‘…’ for all my stream edits. For example listing host ssh keys somewhat prettied up:

(for i in /etc/ssh/ssh_host*pub; do ssh-keygen -lf $i; done) \
  | sed -e 's/\([0-9]\+\)\s\+\(\S\+\)\s*\S\+\s*(\(\S\+\))/\2 (\3-\1)/'

Same with -E:

(for i in /etc/ssh/ssh_host*pub; do ssh-keygen -lf $i; done) \
  | sed -Ee 's/([0-9]+)\s+(\S+)\s*\S+\s*\((\S+)\)/\2 (\3-\1)/'

It’s so convinient that it makes you want to write even more sed expressions!