From the Canyon Edge -- :-Dustin

Wednesday, October 20, 2010

Bikeshed: 1 .. 9 (wicked convenient awk)

I previously introduced the 1, 2, 3, 4, 5, 6, 7, 8, 9 utilities here in my blog as useful awk hacks a few months ago.

Basically, there's one script, installed at /usr/bin/1 and all of the rest are symbolic links back to this one.

The net effect of each of these is to print the Nth column of whatever comes in on standard input. In this way, "1" is sort of an alias for:
  awk '{print $1}'
Each of these accept a single option argument. By default, whitespace is assumed to be the input field separator. You can specify a different character or string here.

For example:
  ls -alF | 5
cat /etc/passwd | 7 :
If you find this useful, install the bikeshed package from Natty, or from the Bikeshed PPA for other versions of Ubuntu.

Cheers,
:-Dustin