coreutils
[Top][All Lists]
Advanced

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

Re: sort : skipping "header" row(s) - possibile new command line option?


From: Leslie S Satenstein
Subject: Re: sort : skipping "header" row(s) - possibile new command line option?
Date: Wed, 19 Nov 2014 14:06:27 +0000 (UTC)

What I understand you want is the head command and tail command integrated with 
sort. 
 
I would find an immediate use for the head command.  If my file had control 
totals, then the tail command would be as useful.
Now, suppose the head option is included and exceeds or equals the total lines 
in the file. What do you propose?
 Regards 
 Leslie
 Mr. Leslie Satenstein
Montréal Québec, Canada


 
      From: Pádraig Brady <address@hidden>
 To: Bradley Dean <address@hidden>; address@hidden 
 Sent: Wednesday, November 19, 2014 8:57 AM
 Subject: Re: sort : skipping "header" row(s) - possibile new command line 
option?
   
On 19/11/14 04:21, Bradley Dean wrote:


> Greetings,
> 
> this is a question about a possible new command-line option for sort
> that I'd be interested in implementing, but I thought I'd throw the idea
> out there first before spending time on an idea that was not going to be
> considered useful. I can't think of how I'd do this other than the way
> I've put together below as an example of an existing workaround.
> 
> When using sort to look at space-delimited data (ie with human-readable
> columns) with a header row (or rows) it's useful to be able to keep the
> header rows at the top/bottom of the data rather than having them end up
> mixed with the data after sorting.
> 
> It's often possible to do this by looking at the data twice (once to
> grab the header, once to sort) - either by dumping to a file or by
> running the generating command twice.
> 
> For example - take some_command which outputs space-delimeted data with
> 1 header row and a fourth numeric column I'd like to sort on:
> 
>  some_command > templog; head -1 templog; tail -n +2 templog | sort -n
>  -k 4
> 
> I think it would frequently be handy to be able to just ask sort to keep
> the header rows aside - especially when doing things like running the
> sort inside a "watch" loop where you'd like to be able to come back to
> it over time and see what each column is.

This has been suggested before, though we're undecided on the need
since there are ways to do this already, albeit a little awkward.
Do any of the methods discussed here suffice?

http://lists.gnu.org/archive/html/coreutils/2013-01/msg00034.html

thanks,
Pádraig.



   

reply via email to

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