user121196 user121196 - 11 months ago 88
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?


Sort the file randomly and pick first 100 lines:

$ sort -R input | head -n 100 >output