Please help .
The script need to first grep for all lines with "C:" as it contains a value
Here the value is 0
1,00: This , is a good script c:0
and then give output of the lines with top 3 highest value for c:
1,00: This , is a nice script c:9999
1,00: This , is a good script c:9998
1,00: This , is a cool script c:9000
1,00: This , is a fun script c:12
So the output should be
1,00: This , is a nice script c:9999
1,00: This , is a good script c:9998
1,00: This , is a cool script c:9000
---------- Post updated at 01:31 AM ---------- Previous
sort -t: -nr -k3 input.txt | head -3
No that didnt work and i think you misunderstood
Not all lines in the file contain the word "c:" and the position of the word would also vary on the line , hence first c: needs to be grepped separately from the file and then the top 10 highest value for it should be printed for it
eg
1,00: This , is a nice script c:9999
1,00: This , is a good script c:9998
1,00: This , is a cool script c:9000
1,00: This , is a fun script c:12
So the output should be
1,00: This , is a nice script c:9999
1,00: This , is a good script c:9998
1,00: This , is a cool script c:9000
awk '/c:/' infile |sort -t: -nr -k3 | head -3
grep "c:" infile |sort -t: -nr -k3 | head -3