I have a file logs.txt
with numbers which repeat:
1 QWE
1 ASD
1 QWE
1 QWE
1 QWE
1 qwe
12
22 qwe
2 aaa
2 vcc
2 xxx
4 asa
44 qwe
4 gfd
4 bcx
5
6 kuy
7
76 lol
5
4 ggg
23
2 ttt
34
5
5
76
5
6
78
99
8
88
7
6
88
88
88
88 wer
88 tyu
99 dsf
78 dfg
78 fgh
78
78 qwe
6 qwe
5
22 qwe
I need to sort them. So the highest should be on top. example: number 1 repeats 20 times, number2 repeats 44 times...
20 1
44 2
1 3
5 4
.....
I run this commands:
awk '{print $1}' logs.txt >> log2.txt
cat log2.txt | uniq -c >> log3.txt
sort -n srp >> log4.txt
tac log4.txt > log5.txt
It works for me but it took much time! I want to put all commands in the file to execute. I need to create a script!