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

1 comment:

  1. if you put this:
    --------------------------
    eval "awk '{print $"$0"}'"
    ---------------------------
    into a file like test.sh
    and then use:
    ln -s test.sh 1
    ln -s test.sh 2
    ln -s test.sh 3
    ln -s test.sh 4
    it will to that.

    ReplyDelete

Please do not use blog comments for support requests! Blog comments do not scale well to this effect.

Instead, please use Launchpad for Bugs and StackExchange for Questions.
* bugs.launchpad.net
* stackexchange.com

Thanks,
:-Dustin