fawk

| No Comments | No TrackBacks

There are a lot of old-school Unix commands that can be strung together to form miniatures programs a solution where one doesn't already exist. Often times, they're great for nothing more than trimming the output from command line programs to make ocular searching easier. awk is one of these great little text processing utilities, though I usually find myself using it in only it's simplest fashion: to print a specific record from a line of input.

Caligula:~$ df -h|awk '{print $2}'
698Gi
298Gi
190Gi

That awk command, '{print $2}', is more than a bit cumbersome to type, so I keyed up a quick function in my .bashrc to make performing this quick operation easier:

Caligula:~$ df -h|fawk 2
698Gi
298Gi
190Gi

And the function:

function fawk {
    first="awk '{print "
    last="}'"
    cmd="${first}$${1}${last}"
    eval $cmd
}

No TrackBacks

TrackBack URL: http://dinomite.net/cgi-bin/mt/mt-tb.cgi/275

Leave a comment

Pages

About this Entry

This page contains a single entry by Drew Stephens published on February 8, 2009 12:26 PM.

Caps Lock to Control in Ubuntu Intrepid Ibex (8.10) was the previous entry in this blog.

United States Personal Savings Rate is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.