Last active
December 21, 2015 13:58
-
-
Save sehrgut/6315894 to your computer and use it in GitHub Desktop.
For OS X and other platforms where you don't have GNU sort, but want a quick way to shuffle lines. This has been done many times before, but most implementations I've seen don't deal equally with filename arguments and stdin.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Licensed under any of GPLv2, MIT, and BSD 2-clause licenses | |
( | |
if [[ $1 ]]; then | |
while [[ $1 ]]; do | |
cat $1 | |
shift | |
done | |
else cat | |
fi | |
) |\ | |
while read line; do | |
echo "${RANDOM}~$line"; | |
done | sort | sed -E 's/^[0-9]+~//' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment