Get random lines from large files in bash
问题 How can I get n random lines from very large files that can't fit in memory. Also it would be great if I could add filters before or after the randomization. update 1 in my case the specs are : > 100 million lines > 10GB files usual random batch size 10000-30000 512RAM hosted ubuntu server 14.10 so losing a few lines from the file won't be such a big problem as they have a 1 in 10000 chance anyway, but performance and resource consumption would be a problem 回答1: Here's a wee bash function for