Archive for August, 2009

field: a small command to print fields from stdin

Something I do a lot is stuff like this: ls -l | awk ‘{print $5″\t”$6}’

Usually… I just want to some subset of the output delimited on whitespace… I might use cut, but cut doesn’t work well if the whitespace varies… For example if is some combination of tabs and spaces.

So I use awk… even the syntax is sort of a nuisance if you are doing something so trivial…. So I recently wrote field.

It is a very small program with usage like: ls -l | field 5 6

Feel free to use it if you like.

It has no warranty, so don’t expect your money back if it piddles on the new rug…

Leave a Comment