|
Blue Forest http://www.lslnet.com at 11:18 on June 26, 2006
(Urgent, please you a) how to delete the document, the number of firms A document is as follows :
111|abc|19990202
111|aaa|20010101
222|dfg|19990202
333|qwe|19990208
444|www|20001202
444|eee|20030311
555|bbb|20020302
666|aaa|20030102
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . (About tens of thousands of firms)
The third domain of time, the problem now is that if the first two records of the same domain, according to the third domain
The time to judge, a new record time effective access to delete the old record time. How to delete access to the old records.
Another great : paper about tens of thousands of firms that do a cycle, time to delete those old records. |
(Urgent, please you a) how to delete the document, the number of firms [code]
Sort-r-t '|' | sort-u-t-n -k1,1 -k3,3 a '|' -k1,1 "b
[/code] |
(Urgent, please you a) how to delete the document, the number of firms [code]sort T "|" flight FILE| awk-F-1 + r "|" 'BEGIN{f=0}{if (f==0) f=1;f1=$1;print $) else if (f1!=$1) {f1=$1; print $ 0}} ' "NEW_FILE[/code]
Aix the test |
(Urgent, please you a) how to delete the document, the number of firms In my hp_ux under test! ! !
Thank biansj
My great gratitude. |
(Urgent, please you a) how to delete the document, the number of firms I believe that if the paper is enormous and the need to implement, using perl efficiency would be much higher
-------------------------------------------------------
#!/usr/bin/perl W
Use strict;
Die "You must apply filename!" if (!$ARGV[0]);
Open TEST, "" $ARGV[0] "
Or die "Something wrong : $!";
My %index;
My %content;
While ( "TEST>) (
Chomp;
S/\|/:/g;
Myttt=split /:/, $_;
If ($index{$ttt[0]}) (
If ($index{$ttt[0]} 60m $ttt[2]) (
$content{$ttt[0]}=$ttt[1];
$index{$ttt[0]}=$ttt[2];
}
) Else (
$index{$ttt[0]}=$ttt[2];
$content{$ttt[0]}=$ttt[1];
}
}
Foreach (sort keys %index) (
Print $_. "|." $content{$_}. "|." $index{$_}. "\n";
}
-------------------------------------------------------- |
(Urgent, please you a) how to delete the document, the number of firms ...
Oh, you are trying to finish their operations, and not even a ~~~ Shashi, but to challenge your illnesses, Kazakhstan 哈~~~
Biansj indeed spicy ginger is the old way, then the words on the Taiwan issue and the fastest ~ ~ formidable!
Taige Unfortunately, very beautiful, not the consent of the landlord, the landlord may not test is successful, simply because of a flower left out brackets Oh (f=1 front, left to spend in brackets)
Perl script easily the fastest cat, after all, than the shell or perl interpreter efficient.
But this is not the fastest, the faster below. Awk is used to write, but because I did not use classification, accounting for the fees. Super row for a large number of data, it is more apparent.
[code]#!/bin/sh
# Trip on most systems use awk, nawk not write
Nawk F '|' 'BEGIN {n=0}
{
If ($ in item) (
If (item[$1] "$ 3) (
Value[$1] = $ 2
Item[$1] = $ 3
}
Next
}
Prim[n++] = $ 1
Value[$1] = $ 2
Item[$1] = $ 3
}
Sound --
For (i=0; i<n; i++) (
Print prim[i] "|" value[prim[i]] "|" item[prim[i]]
}
) 'Filename
[/code]
The following are my test record of 1.08 million.
# L filename[/b] [b]wc
1080008 filename
(Cmd used to test time)
# [b]for I do echo in rp.*; "==========$i==========="; Time. /$i; Done[/b]
==========rp.biansj.sh===========
111|aaa|20010101
222|dfg|19990202
333|qwe|19990208
444|www|20001202
555|bbb|20020302
666|aaa|20030102
2m28.822s biansj real needs of about 2 minutes 27 seconds.
User 2m25.220s Oh, appears to be quite different from the results with others in the 444, where, what may be missed
Sys 0m2.050s
==========rp.elium.pl===========
111|aaa|20010101
222|dfg|19990202
333|qwe|19990208
444|eee|20030311
555|bbb|20020302
666|aaa|20030102
Real cat is about 50 seconds easily 0m51.667s
User 0m49.660s
Sys 0m0.150s
==========rp.sleeve.sh===========
111|aaa|20010101
222|dfg|19990202
333|qwe|19990208
444|eee|20030311
555|bbb|20020302
666|aaa|20030102
Even the real 0m16.763s, about 16 seconds, haha, admiring its own ice cream ~~~
User 0m15.710s
Sys 0m0.190s
==========rp.taige.sh===========
111|aaa|20010101
222|dfg|19990202
333|qwe|19990208
444|eee|20030311
555|bbb|20020302
666|aaa|20030102
Taige real 2m43.024s, about 2 minutes 40 seconds
User 2m41.200s
Sys 0m1.250s
I will not fight you? _ |
(Urgent, please you a) how to delete the document, the number of firms : Evil : tea sister, aside retrieve heart!
————————————————————
Aunt tea when I can have half of the IQ? ! : Roll : |
(Urgent, please you a) how to delete the document, the number of firms Stinky sleeves!
Yes indeed!
Learning! |
(Urgent, please you a) how to delete the document, the number of firms -->
Who now has the companion of a fair lady you have good, I eat ice cream, I eat the largest most expensive, slaughter, you! : : : Wink wink :
See you next time I would dare challenge illnesses!
However, I do not teeth! : Cry : : cry : |
(Urgent, please you a) how to delete the document, the number of firms -->
Kazakhstan much greater
: D |
(Urgent, please you a) how to delete the document, the number of firms Surprise, so many people said you tea Aunt! Wind! Withdraw!
Man, I have to eat, what time was I forgot to notice! |
(Urgent, please you a) how to delete the document, the number of firms Master ah
I should learn to start tomorrow and PerlProgramming AWK |
(Urgent, please you a) how to delete the document, the number of firms ...
: P
Nevertheless, the stubborn! ! ! |
(Urgent, please you a) how to delete the document, the number of firms Than a cow, formidable and admirable :)
Tea sister, Shanghai, I invite you to eat ice cream :)
The cheapest kind, Oh, my poor :) |
(Urgent, please you a) how to delete the document, the number of firms -->
噻 wow! Leading to a visit to ~~~~
Geee~~~ certainly is not poor, the poor are very generous. Kuanye certainly is!
Robbery! ! ! Raise their hands! ! ! |
(Urgent, please you a) how to delete the document, the number of firms I have the copies? |
(Urgent, please you a) how to delete the document, the number of firms ...
Who hopefully will mean to us how small a small niece? :)
The flowers are Oumen illustrated, good words D~~~ |
(Urgent, please you a) how to delete the document, the number of firms -->
Sister in the tea that, I renewed my hp_ux last choice is through your script, thank you.
Thank tea sister |
(Urgent, please you a) how to delete the document, the number of firms I negligence
Or Xiu (all) Strong! |
(Urgent, please you a) how to delete the document, the number of firms -->
Halo 啊~~ |
| |