This question already has an answer here:
In a Bash script, I want to pick out N random lines from input file and output to another file.
How can this be done?
dogbane
Use shuf with the -n option as shown below, to get N random lines:
shuf -n N input > output
user881480
Sort the file randomly and pick first 100 lines:
$ sort -R input | head -n 100 >output
来源:https://stackoverflow.com/questions/9245638/select-random-lines-from-a-file