79vsvg
Last Updated: February 25, 2016
·
1.966K
· simonwhitaker
54c043fe2197d9e27f577f66a9beddb5

Show a random sample of lines from a text file

Using the king of scripting languages, Perl.

For example, to get a random set of words from /usr/share/dict/words

perl -ne 'print if rand > 0.999' /usr/share/dict/words

With 0.999 you'll get approximately one line out output per thousand lines of input. Tweak accordingly.

2 Responses
Add your response

1012
3350a86acbaa6995dfc5baa4219e9d30

I like this one, even though it is very slow on large files, because it shuffles the entire file. Shows 15 random lines from file:
cat /usr/share/dict/words | sort -R | tail -15

over 1 year ago ·
1013
618176d863cad625685d958fb66ba1f2

Simon, nice bio: "Compiled in 1972 with the verbose option enabled." Hehe!

over 1 year ago ·