bug-coreutils
[Top][All Lists]
Advanced

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

Re: Feature request: counting fields/chars from the right.


From: Jim Meyering
Subject: Re: Feature request: counting fields/chars from the right.
Date: Wed, 13 Sep 2006 23:36:38 +0200

Paul Eggert <address@hidden> wrote:
> "Chris Dew" <address@hidden> writes:
>> I was therefore thinking that cut could have a '-r, --count-from-right'
>> switch, which would make all  field/column values 'right-relative'.
>
> Thanks for the suggestion, but wouldn't it be better to allow people
> to mix left-relative and right-relative fields in the same call to
> 'cut'?
>
> How about preceding the Python/Ruby-like range with "@"?  Then we can
> get everything Python/Ruby-like all at once, including zero origin
> (which is clearer to me, at least).  We can also use : instead of - to
> separate the values, to avoid ambiguity.  Thus,
>
> cut -f @0 (instead of cut -f 1)
> cut -f @1:3 (instead of cut -f 2-3)
> cut -f @1:-1 (to get the sort of behavior you want)
>
> Jim Meyering has the final say on this sort of thing of course, but I
> think if we're going to do Python/Ruby-style ranges we should go all
> the way.  (With "cut" and with other programs like "sort" too, but one
> program at a time, I suppose.)

Hi Paul,

I admit that this would be a nice feature to have, but I confess to
being very reluctant to add it.  Especially considering that awk,
perl, ruby etc. one-liners can provide the desired functionality,
as Bob demonstrated.

However, those languages aren't as accessible these tools.  Here's an
idea: start maintaining a section in coreutils.texi with a collection
of scriptlets and/or examples showing how to do things like this with
other tools.  They could serve as examples of the limitations of the
coreutils, as well as ideas for future extensions.

Then, if enough people end up requesting that a particular one-liner be
added as an extension, there's more history.  But odds are that once
someone finds a way to solve his/her problem, it won't matter if it's
a program from coreutils or from some other package.




reply via email to

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