Sorting on the last field of a line

后端 未结 11 1025
暗喜
暗喜 2020-12-05 04:06

What is the simplest way to sort a list of lines, sorting on the last field of each line? Each line may have a variable number of fields.

Something like



        
11条回答
  •  猫巷女王i
    2020-12-05 04:50

    I want this list sorted on the filenames, which all start with numbers indicating the order the files should be read.

    find . | sed 's#.*/##' | sort
    

    the sed replaces all parts of the list of results that ends in slashes. the filenames are whats left, and you sort on that.

提交回复
热议问题