user121196 user121196 - 4 months ago 23x
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