|
From: | Mark E. Shoulson |
Subject: | Re: sort --head |
Date: | Wed, 19 Jun 2024 14:48:10 -0400 |
User-agent: | Mozilla Thunderbird |
~mark On 6/18/24 21:49, Mark E. Shoulson wrote:
Hi. New here, to post a patch which I hope will inspire someone to do a better job.I can't really believe that for all these years, we still so very, very often run sort(1) and pipe it through head(1) or tail(1), because we only want the top/bottom 20 lines or whatever. That means we're sorting a potentially gigantic list of lines but not caring about most of the information.I'm attaching a patch that adds `--head` and `--tail` options to sort(1), so you say `sort --head=20` (which is equivalent to saying `sort --tail=-20` and vice-versa). I've worked this into sort(1) VERY VERY BADLY, I'm sorry to say, but maybe someone with better familiarity with the code can do it better. Basically, I'm special-casing out the situation when --head is active and doing my own thing with it, and then lying to the rest of the program about it. But it works, anyway.
[Prev in Thread] | Current Thread | [Next in Thread] |