Richard Lee wrote:
I am running this command on over 2 gigs worth of lines....
which one should be faster?
cut -d'|' -f21 * | sort | uniq -c | sort
With cut the fields are numbered starting at 1.
perl -F"\|" -lane 'print $F[21]' * | sort | uniq -c | sort
With perl array indexes are numbered starting at 0. So do you want to
sort and compare the 21st field or the 22nd field?
or is there faster ways to do this on perl?
perl -ne'$d{ ( split /\|/ )[ 20 ] }++ }{ printf "%7d %s\n", $d{ $_ }, $_
for sort { $d{ $a } <=> $d{ $b } || $a cmp $b } keys %d' *
John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order. -- Larry Wall
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/