I often need to randomly sort a file. I’m not aware of any standard bash or GNU command that does this, so I just wrote this very short script. There may be an even shorter/faster/more efficient way to do this, but I thought I’d post this as it might be helpful to a Linux newbie trying to accomplish the same task. Just put this in a file—e.g., “randomsort”; make it executable; and then pipe whatever you want to randomize into it (cat file_to_be_randomized | randomsort or randomsort file_to_be_randomized), and voila, you’re done.

 #!/usr/bin/perl my @array = <>; while (@array) { my $element = int(rand(@array)); print $array[$element]; delete $array[$element]; } 

Feel free to comment if you’ve got an easier solution.