sort text utility features a non-standard
-R option to randomize input lines.
sort does not have this extension. Is there similar functionality available in another text filter?
Running this would install Homebrew.
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Then just follow the installation instructions. When Homebrew is installed, run
brew install coreutils
This will install GNU sort as
gsort, so you can use it like
sort on any GNU Linux.
Alternatively, have a look at these Stack Overflow questions, which mention a couple of methods:
Or take a look at this commandlinefu.com page:
On OS X, if you don't want to install homebrew (but you really should), you could use
perl -MList::Util -e 'print List::Util::shuffle <>'
ruby -e 'puts STDIN.readlines.shuffle'
coreutils package, but then you've to add
/usr/local/bin to your
~/.bashrc file, for example:
Alternatively you can try
ex -s +"%s/^/\=reltimestr(reltime())[-2:].' '" +"sort n" +"%s/^\S* //" +%p -cq! /dev/stdin
Source: How to shuffle a list in vim?
You could install the
rl command via homebrew (
brew install randomize-lines).
It is quite fast and has options to limit the number of returned items, as well as specify the delimiter (space instead of line feed, for instance).
(See also https://stackoverflow.com/a/42056195/43615.)