An inexact clone of GNU shuf implemented in Python
An inexact clone of GNU shuf. Free, implemented in Python.
Install
$ pip install pyshuf
or
$ easy_install pyshuf
Usage
Same as shuf, but the script is invoked with pyshuf. Read the GNU manual for shuf for more details. I haven’t used shuf – I wrote this because it didn’t come standard on MacOS.
“Cookbook”
Generate a random number from 0 to 99
$ pyshuf -i 0-99 -n 1
73
Pick a random word from the dictionary (dictionary location may vary)
$ pyshuf --input-file /usr/share/dict/words -n 1
irreflectiveness
Shuffle the first 10 words from the dictionary
$ head /usr/share/dict/words | pyshuf
aardvark
aalii
Aaron
a
aa
Aani
aam
aardwolf
A
aal
Use input from the command line
$ pyshuf --echo one two three four five
four
two
three
one
five
Features I implemented
--e, --echo
-i, --input-range
-n, --head-count
Features I have not implemented
-o, --output-file
--random-source
-r, --repeat
-z, --zero-terminated
Features I added that are not in GNU shuf
--input-file specify an input file to read from