Next | Welcome to my ~/bin | 11 |
#!/usr/bin/perl
my $field = shift or usage(); $field -= 1 if $field > 0;
while (<>) { chomp; my @f = split; print $f[$field], "\n"; }
sub usage { print STDERR "$0 fieldnumber\n"; exit 1; }
The $field -= 1 is so that f 1 emits the first column of input
But why if $field > 0?
That's so that this works:
ls -l | grep 'May 22' | f -1
f -1 emits the last column of input
All this is inconsistent
In particular, f 0 and f 1 do the same thing
That's OK
Next | Menu | Copyright © 2005 M. J. Dominus |