See the thread improving the efficiency of a script on taking random samples.
In reply to Re: grabbing random n rows from a file by ambrus in thread grabbing random n rows from a file by punkish