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.

Split a spreadsheet into multiple files with the GNU/Linux command line

Have you ever wanted to split a spreadsheet into several spreadsheets according to the contents of a particular field? For example, you might have a music tracks spreadsheet with an 'artist name' field, and you want separate spreadsheets for each artist, with the usual field names along the top of each new spreadsheet.

You can split a spreadsheet by copying and pasting the different sections into new spreadsheets if there aren't many records. If there are lots of records, this manual approach can be pretty tiring. For splitting very large spreadsheets, most users turn to special stand-alone programs (in the Excel world) or fairly complicated macros (Excel, Open/LibreOffice Calc).

I split my spreadsheets using the GNU/Linux command line, as explained in this article. It's another of my trademark ugly hacks, but it works well and the command line steps can be combined into a script which runs fast and reliably.

Subscribe to RSS - spreadsheet