Sort with header/skip-lines support (original) (raw)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
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 |
Hello,
I'd like to re-visit an old issue: adding header-line/skip-lines support to 'sort'.
It has been discussed few times in the past, but IMHO the suggested workarounds fall short:
- Sometimes using 'bash' specific constructs [1]
- No error checking (e.g. running head/tail/sed without checking for errors)
- Using multiple input files is convoluted.
- 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=. RUN_EXPENSIVE_TESTS=yes
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).
Thanks, -gordon
[1] - bash work-around: http://lists.gnu.org/archive/html/coreutils/2010-11/msg00084.html [2] - no pipe support: http://lists.gnu.org/archive/html/bug-coreutils/2007-07/msg00215.html [3] - Jim's patch: http://lists.gnu.org/archive/html/coreutils/2010-11/msg00091.html
0001-sort-add-skip-lines-N-feature.patch.xz
Description: application/xz
- Sort with header/skip-lines support,Assaf Gordon <=
- Re: Sort with header/skip-lines support, Pádraig Brady, 2013/01/10
* Re: Sort with header/skip-lines support, Assaf Gordon, 2013/01/11
* Re: Sort with header/skip-lines support, Pádraig Brady, 2013/01/11
* Re: Sort with header/skip-lines support, Assaf Gordon, 2013/01/11
* Re: Sort with header/skip-lines support, Pádraig Brady, 2013/01/11
- Re: Sort with header/skip-lines support, Pádraig Brady, 2013/01/10
- Prev by Date:Re: [PATCH] cp caching
- Next by Date:Re: date conversion from locale-specific format to any other date-format
- Previous by thread:Re: Make mv work better with SELinux.
- Next by thread:Re: Sort with header/skip-lines support
- Index(es):