npub1y0emt2wlpsezcnmxtyrpf33qe7gwy5u8yzssvv6uw53em0k32t7q7smm9n (npub1y0e…mm9n) I think that there is actually a binary here. I think doing it as an awk, for example, would be brittle.
To me, this is actually a common and useful pattern and in fact is just a general case of the history command.