[Top][All Lists]

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

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

From: Pádraig Brady
Subject: Re: sort : skipping "header" row(s) - possibile new command line option?
Date: Wed, 19 Nov 2014 13:57:28 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0

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?


reply via email to

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