awk

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.

Save time with AWK print

Since discovering AWK last year I've been using it regularly with tables of data. It seems like everything I do with those tables is faster and easier with AWK on the command line than the same jobs would be with spreadsheet software.

Below are a couple of examples that demonstrate the handiness of the print command in AWK. If you've never used AWK before, see the links at the end of the article for a quick introduction to the basics.

Subscribe to RSS - awk