How to sort on column for rows containing a certain word

前端 未结 4 959
耶瑟儿~
耶瑟儿~ 2021-02-02 18:32

I want to sort on a certain column only for rows containing a certain word. I don\'t want to see rows not containing that word. For example I have this text file:



        
4条回答
  •  感情败类
    2021-02-02 18:59

    Pipe your input to an external command:

    :%!grep sdf | sort -n -k3
    

    Details:

    1. select the whole content using '%'
    2. pipe it to an external command using '!'
    3. grep onyl the lines containing 'sdf'
    4. sort these lines numerically (-n) on the third field (-k3)

提交回复
热议问题