[Top][All Lists]

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

Re: enhancement suggestions for "sort" and text editor

From: Eric Blake
Subject: Re: enhancement suggestions for "sort" and text editor
Date: Fri, 14 Dec 2012 14:19:16 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/17.0 Thunderbird/17.0

On 12/14/2012 02:02 PM, john wrote:

> In particular I wish to enter text into predefined (fixed location)
> fields in a record as opposed to variably delimited fields.  In other
> words emulate the punched card record where card columns are assigned to
> particular data character columns.  Those card columns then just become
> a text column range of a single record.  If I could just set perhaps 10
> arbitrary tab stops (in any simple editor), it would be sufficient for
> this purpose.  The tab key would just advance to the next stop in
> succession, tho not necessarily regularly spaced.

Sounds like you are talking in part about 'expand -t', which lets you
re-expand tabs according to your choice of pre-defined stops.  Beyond
that, your question is out of scope for coreutils, and better directed
to the editor of your choice (I'm quite sure that emacs is probably
going to have something that does what you want, although I don't use
arbitrary tab stops enough to be able to tell you off-hand how to get at
that feature)

> The companion problem was using "sort" to accept keys based upon fixed
> character columns vs delimited fields.  I would like to sort keys in
> specific columns without regard to potentially missing fields.  There
> appears to be character positioning of keys, but relative to a delimited
> key field.  Perhaps a notation like a field "0" with a character
> position could refer to just absolute character positions e.g. "-k0.5,
> 0.9" indicating a key of character columns 5 thru 9, regardless of what
> may or may not reside on characters 1-4.

This can already be accomplished with a wise choice of -d (here, in bash

sort -d$'\n' -k1.5,1.9

which says to break fields at newline characters; since newline also
breaks records, that means each entire line will all be field 1.

Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library

Attachment: signature.asc
Description: OpenPGP digital signature

reply via email to

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