Select Random Lines from file in Linux

Being able to select random lines from a file in Linux can be very helpful and convenient. There are a few easy ways to do this, including using the shuf utilty. shuf is included on many Linux/Unix systems as part of GNU coreutils. GNU coreutils can be easily installed if not already.

Selecting Random Lines with shuf

The examples below show some common ways to use shuf to randomize lines in a file or from standard input in Linux.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">