Skip to content

Instantly share code, notes, and snippets.

@amacinho
Created July 5, 2012 17:55
Show Gist options
  • Save amacinho/3055198 to your computer and use it in GitHub Desktop.
Save amacinho/3055198 to your computer and use it in GitHub Desktop.
Shuffle the lines of a file -- the command line
# For other ways of doing this see this question on stackoverflow: http://stackoverflow.com/questions/2153882/how-can-i-shuffle-the-lines-of-a-text-file-in-unix-command-line
cat myfile | awk 'BEGIN{srand();}{print rand()"\t"$0}' | sort -k1 -n | cut -f2- > myfile.shuffled
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment