Sorting on the last field of a line

后端 未结 11 1022
暗喜
暗喜 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条回答
  •  无人及你
    2020-12-05 04:50

    something like this

    awk '{print $NF"|"$0}' file | sort -t"|" -k1 | awk -F"|" '{print $NF }'
    

提交回复
热议问题