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?
Use shuf with the -n option as shown below, to get N random lines:
shuf
-n
N
shuf -n N input > output
2.1m questions
2.1m answers
60 comments
57.0k users