how do I sort lists like the one below using sort or any related commands?


I want to sort them according to the last word which is the year chronologically?

N.B basically something like sort -t. -k-1 although -1 is not allowed. Any command just to address the last part?

  • the third word meaning the word after 3 dots from the start of the line
    – Sol
    Commented Jun 8, 2020 at 22:52
  • not really because they are not columns rather just words and numbers just connected with dots
    – Sol
    Commented Jun 8, 2020 at 22:54
  • 1
    You just have to tell sort that your field separator is the dot. Check the -t flag. Commented Jun 8, 2020 at 22:56
  • 2
    You know, one of the conditions of asking here is to do some research first. Sometimes people will give you an answer, but usually you have to show that you've tried. The command sort sorts based on fields (see the answer linked above). By default the field separator is whitespace, with -t. the field separator will be a dot. You' most likely can pick it up from there. Commented Jun 8, 2020 at 23:00
  • Yes, using both flags. Commented Jun 8, 2020 at 23:07

1 Answer 1


With a Schwartzian transform

... | awk -F. -v OFS=. '{print $NF, $0}' | sort -t. -n -k1,1 | cut -d. -f2-

where ... is whatever command you use to produce the list.


Not the answer you're looking for? Browse other questions tagged .