I have a file that needs organized a number of repeats, my file has 6 rows and 3120 lines each member has 1 or 2 digits, total 18720 numbers with one or 2 digits.
I would like to count how many 1, how many 2, how many 3 so on to how many 45 I have in my file and output organanize most reported number to less repeated. Example:
5 7 13 25 26 44
12 21 26 28 32 44
10 20 22 26 40 44
13 18 19 20 22 23
9 15 17 19 22 43
10 19 28 29 37 45
2 8 12 13 22 35
3 23 24 26 38 39
3 14 19 20 33 43
2 3 8 35 36 43
2 8 25 29 37 43
3 24 27 29 38 44
5 20 23 32 33 40
11 17 22 26 33 36
1 6 31 32 39 44
4 22 27 31 36 43
3 6 18 22 35 44
11 13 24 28 32 33
17 22 27 29 42 44
8 9 16 23 29 44
13 19 20 33 37 40
18 21 29 31 34 44
14 15 20 31 32 41
6 32 33 40 41 43
11 17 18 31 43 44
1 9 10 22 24 34
6 8 9 35 37 38
14 18 21 36 40 43
11 16 17 32 34 38
1 5 14 22 23 24
5 19 21 22 32 45
12 17 20 22 32 44
9 27 32 38 42 44
4 12 16 26 42 45
6 7 8 16 39 42
5 6 13 18 27 28
Output:
most repeted first with number of repetion
5=30 Five reapeted 30 times
4=28 Four reapeted 28 times
.........
.........
.........
35=0 Thirty five repeated 0 times
I try this but doesn't work and I'm not expert to change code
$ tr -s " " "\n" | sort | uniq -c | sort -n r | awk '{print $2 " = " $1}'
$ awk -v RS='\\s+' '{cnt[$0]++} END{PROCINFO["sorted_in"]="@val_num_desc"; for (i in cnt) print i" = "cnt[i]}' file
$ tr -s ' ' '\n' <file | sort | uniq -c | sort -nr | awk '{print $2 " = " $1}'
$ tr -s ' ' '\n' <nums | sort | uniq -c | sort -k1,1nr -k2n | awk '{print $2 " = " $1}'
$ awk -v RS=" +|\n" '{a[$1]++}END{for(x in a)printf "%d = %d\n",x,a[x]}' file
$ awk -v RS=" +|\n" '{a[$1]++}END{for(x in a)printf "%d = %d\n",x,a[x]}' f|sort -nr -k3