Linux 文件打乱顺序
cat in.txt | awk 'BEGIN{srand()}{print rand()"\t"$0}' | sort -k1,1 -n | cut -f2- > out.txt
sort -R in.txt > out.txt
后者要计算每行的hash,再排序,在文件内容比较多的情况下前者要比后者快得多
参考文献:
http://blog.csdn.net/littlewhite1989/article/details/39899609
https://blog.csdn.net/bitcarmanlee/article/details/52718146