user121196 user121196 - 1 year ago 172
Linux Question

Select random lines from a file in bash

in bash script I want to pick out N random lines from input file and output to another file.
how can this be done?

Answer Source

Sort the file randomly and pick first 100 lines:

$ sort -R input | head -n 100 >output
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download