Dear all,
Shuffling the lines
I would like to perform the following tasks using awk. I would be grateful for any advices you might have.
1. Shuffle the lines by field 1 (groups 111, 112). That is, within each group shuffling is undertaken independently.
2. After that print out the first 5 lines by groups.
3. Repeat steps 1 to 2 say 100 times and print to file1.txt, file2.txt,... file100.txt.
The number of groups is large in my case.
Input
111 1032192
111 2323476
111 1698881
111 2451712
111 2013780
111 888105
112 2331004
112 1886376
112 1189765
112 1877267
112 1772972
112 574631
Output
1 st time, the output could be
111 2323476
111 1698881
111 2451712
111 2013780
111 888105
112 1886376
112 1189765
112 1772972
112 574631
112 2331004
2nd time, the output could be
111 2451712
111 2013780
111 1698881
111 2323476
111 888105
112 1877267
112 1772972
112 2331004
112 1886376
112 574631
Thank you very much.
Cheers,
T
Shuffling the lines
I would like to perform the following tasks using awk. I would be grateful for any advices you might have.
1. Shuffle the lines by field 1 (groups 111, 112). That is, within each group shuffling is undertaken independently.
2. After that print out the first 5 lines by groups.
3. Repeat steps 1 to 2 say 100 times and print to file1.txt, file2.txt,... file100.txt.
The number of groups is large in my case.
Input
111 1032192
111 2323476
111 1698881
111 2451712
111 2013780
111 888105
112 2331004
112 1886376
112 1189765
112 1877267
112 1772972
112 574631
Output
1 st time, the output could be
111 2323476
111 1698881
111 2451712
111 2013780
111 888105
112 1886376
112 1189765
112 1772972
112 574631
112 2331004
2nd time, the output could be
111 2451712
111 2013780
111 1698881
111 2323476
111 888105
112 1877267
112 1772972
112 2331004
112 1886376
112 574631
Thank you very much.
Cheers,
T