Finding changes in a sorted list: a trick

Think of a phone directory listing with a lot of Browns followed by some Brownes, Brownings and Brownleys. Is there a simple way to identify the places in the sorted list where Brown changes to Browne, Browne to Browning and Browning to Brownley?

If you're a programmer, you've probably just thought of an 'if, then' test for items in the list. If you're an AWK-lover (like me!) you may have started thinking about the getline option.

There's another and more interesting way to do this job on the GNU/Linux command line, as explained below.

Subscribe to RSS - sed