Shuffle or pick random lines from a file

November 13, 2017

There comes a day in the life a developer when one needs to choose random lines from a text file.
This is useful for a myriad of reasons, like taking a random sample of a CSV file, or shuffling
the code of your coworkers, just for fun.

There are multiple tools in the UNIX toolbox to solve this problem, but the shuf utility is
by far the most elegant: