Dear all,
I wish to shuffle the lines (the rows) of a file at random then print out to different five files.
But I keep having exactly the same order of lines appeared in file1 to file5. The random generation process does not work properly. I would be grateful for any advices.
#!/bin/bash
for i in seq 1 5
do
cat shuffling.txt | awk 'BEGIN{srand();} {print rand()"\t"$0}' | sort -k2 -k1 -n | cut -f2- > file$i.txt
done
Input shuffling.txt
111 1032192
111 2323476
111 1698881
111 2451712
111 2013780
111 888105
112 2331004
112 1886376
112 1189765
112 1877267
112 1772972
112 574631
Cheers,
T