coreutils
[Top][All Lists]
Advanced

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

Re: Enhancement Request: sort: skip table caption (or just a specified n


From: Assaf Gordon
Subject: Re: Enhancement Request: sort: skip table caption (or just a specified number of lines)
Date: Thu, 5 Nov 2020 10:47:34 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.3.1

Hello,

On 2020-11-05 10:23 a.m., Michael Mess wrote:
I have a feature request for the sort command:
I would like to sort a table but do not want to sort the column names a
the top. Thus the column names or a specified number of lines should be
just given out as they are, unsorted.

This has been discussed few times in the past,
please see discussion (and with further links to other relevant postings) at:
  https://debbugs.gnu.org/cgi/bugreport.cgi?bug=22057



I know there is a workaround, but this is not so handy/comfortable
and has other disadvantages:

for a in ColumnName 4 2 3 1 ; do echo $a ;done | ( sed -u 1q ; sort
-n )


As for handy/comfortable, you can use create a shell alias or a shell function, e.g.:

  $ alias sortcap="(sed -u q1 ; sort)"
  $ printf "%s\n" ColumnName 4 2 3 1 | sortcap
  ColumnName
  1
  2
  3
  4

But also (shameless plug), long ago I wrote a perl wrapper
for 'sort' that hides these details and accepts the same parameters as
'sort' with addition of "--header N" argument, similar to your requested "--caption".
https://github.com/agordon/bin_scripts/blob/master/scripts/sort-header.pl


Hope this helps.
 - Assaf






reply via email to

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