Is there a way to ignore header lines in a UNIX sort?

后端 未结 12 2229
余生分开走
余生分开走 2020-11-28 21:02

I have a fixed-width-field file which I\'m trying to sort using the UNIX (Cygwin, in my case) sort utility.

The problem is there is a two-line header at the top of t

12条回答
  •  难免孤独
    2020-11-28 21:20

    head -2  && nawk 'NR>2'  | sort
    

    example:

    > cat temp
    10
    8
    1
    2
    3
    4
    5
    > head -2 temp && nawk 'NR>2' temp | sort -r
    10
    8
    5
    4
    3
    2
    1
    

提交回复
热议问题