Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have the following problem concerning the sorting of a content of a file. I have a file called points.txt and it contains the following table of data:


Now how can I list the following list in numerical order (highest first) or how can I list the three names with highest scores. I have tries the following by they don't seems to work

sort -n -k 1,1 points.txt
sort -n points.txt
sort -n ^: points.txt
share|improve this question
Please use meaningful titles, not “meta-titles” like “Question about X”. We know you have a question, you're posting a question. The title should describe what your question is about, it should be the gist of your question. – Gilles Nov 17 '13 at 20:31

If you looking for the top 3

sort -k2,2rn -t: points.txt  | head -n 3 | cut -f1 -d:

-k specifies the sort field, the parts that follow indicate the following

2,2 - sort key starts and ends at field 2

n - numeric sorting

r - reverse sorting

-t is used to specify the field separator, which in this case is :

share|improve this answer
could you explain this part more in details: -k2,2rn -t: – cash Nov 16 '13 at 17:58
@cash, added some details. Try man sort and info sort on your installation for documentation – iruvar Nov 16 '13 at 18:04

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.