[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Sort with header/skip-lines support

From: Assaf Gordon
Subject: Sort with header/skip-lines support
Date: Thu, 10 Jan 2013 16:57:00 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.4) Gecko/20120510 Icedove/10.0.4


I'd like to re-visit an old issue: adding header-line/skip-lines support to 

It has been discussed few times in the past, but IMHO the suggested workarounds 
fall short:
1. Sometimes using 'bash' specific constructs [1]
2. No error checking (e.g. running head/tail/sed without checking for errors)
3. Using multiple input files is convoluted.
4. Suggestions work for regular files, but not for pipes [2].

The attached draft patch is based on Jim Hester's patch [3], rebased to the 
latest sort, with some fixes and tests.
It seems to work fine, except one glaring omission: it only works when output 
is STDOUT because creating the output file is a brute-force ugly hack.

The syntax is
  sort --skip-lines=N [other options]

The two tests are:
  make check TESTS=tests/misc/sort-skip-lines SUBDIRS=.
  make check TESTS=tests/misc/sort-skip-lines-bigfiles SUBDIRS=. 

If this is something you are willing to consider, I'm happy to hear comments 
and suggestions and improve it.

Alternatively, perhaps this is a good candidate for a "contrib" script, but I'm 
not sure how do go about developing a shell script that is posix compliant, has 
robust error checking, and still be a full 'drop-in' replacement for sort (many 
options combinations).


[1] - bash work-around:
[2] - no pipe support:
[3] - Jim's patch:

Attachment: 0001-sort-add-skip-lines-N-feature.patch.xz
Description: application/xz

reply via email to

[Prev in Thread] Current Thread [Next in Thread]