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

后端 未结 12 2201
余生分开走
余生分开走 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:38

    Here is a version that works on piped data:

    (read -r; printf "%s\n" "$REPLY"; sort)
    

    If your header has multiple lines:

    (for i in $(seq $HEADER_ROWS); do read -r; printf "%s\n" "$REPLY"; done; sort)
    

    This solution is from here

提交回复
热议问题