GNU bug report logs - #12482
Feature Request: support for int, octal, and hex types in seq --format

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: coreutils; Severity: wishlist; Reported by: Craig Sanders <cas@HIDDEN>; dated Fri, 21 Sep 2012 01:06:02 UTC; Maintainer for coreutils is bug-coreutils@HIDDEN.

Message received at 12482 <at> debbugs.gnu.org:


Received: (at 12482) by debbugs.gnu.org; 21 Sep 2012 15:12:09 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Sep 21 11:12:09 2012
Received: from localhost ([127.0.0.1]:47267 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.72)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1TF4tk-00043p-KB
	for submit <at> debbugs.gnu.org; Fri, 21 Sep 2012 11:12:09 -0400
Received: from taz.net.au ([203.16.167.1]:53558)
	by debbugs.gnu.org with esmtp (Exim 4.72)
	(envelope-from <cas@HIDDEN>) id 1TF4tg-00043c-Ri
	for 12482 <at> debbugs.gnu.org; Fri, 21 Sep 2012 11:12:07 -0400
Received: by taz.net.au (Postfix, from userid 1000)
	id 88FB462D80C; Sat, 22 Sep 2012 01:10:24 +1000 (EST)
Date: Sat, 22 Sep 2012 01:10:24 +1000
From: Craig Sanders <cas@HIDDEN>
To: 12482 <at> debbugs.gnu.org
Subject: Re: bug#12482: Feature Request: support for int, octal, and hex
	types in seq --format
Message-ID: <20120921151024.GH19324@HIDDEN>
References: <20120921003711.GC19332@HIDDEN>
	<A75C39900FCF0B42A2CE8B26F837D2C306B4C6@HIDDEN>
	<87wqzn94am.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <87wqzn94am.fsf@HIDDEN>
User-Agent: Mutt/1.5.21 (2010-09-15)
X-Spam-Score: -4.7 (----)
X-Debbugs-Envelope-To: 12482
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.13
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -4.7 (----)

On Fri, Sep 21, 2012 at 10:19:13AM +0200, Jim Meyering wrote:
> Voelker, Bernhard wrote:
> > Craig Sanders wrote:
> >
> >> seq only supports floating point types like f and g in the --format
> >> string.
> >>
> >> Other types, including i,d,o,u,x,X would also be useful.
> >>
> >> e.g. "seq --format 'prefix%02isuffix' 1 50" to print zero-padded
> >> 1-50 with user-specified prefix and suffix strings.
> >
> > IMO custom format strings for pre- or suffixing are not seq's job.

the printf formats I suggested for seq are not specifically about
prefixing or suffixing, they were just part of an example..

what i requested was non-floating point formats (the suffix and prefix
strings are just a side-benefit of printf) - decimal, octal, and hex
integer printf formats d,o,x, etc. if it supports floating-point, why
not fixed or int?

in fact, why floating-point at all? i can think of hundreds of uses in
a shell script for printf-formatted ints from seq (and some for hex and
even a few for octal), but not a single one for floating point. i'd
use perl or python or something else if i wanted to do floating-point
calculations (perl has a nice Math::BigFloat module and python, of
course, has numpy and scipy).


> I agreed, initially.  The texinfo documentation gives examples
> of how to convert seq output to hexadecimal (%x) using printf:

yes, i know there are numerous ways to post-process seq's output.  I
even included a few in my answer to the stackexchange question i linked
to.

if there's some reason why floating point is possible but
the integer formats are not then fair enough....but it doesn't
make sense to me to arbitrarily declare that floating-point
printf support is OK but not integer.


the examples using printf and xargs and so on are both obvious and
missing the point. this bug report is not about them. it's about seq's
incomplete support for printf.


> (the disadvantage with this approach is that you have to pre-compute
> the width and use that number in the printf format, whereas in Bernie's
> example, that's done automatically by seq -w.  This suggests that seq's
> --equal-width (-w) option *would* be handy in conjunction with the requested
> integer format directives.  Then, we'd get the benefit of -w along with
> the more direct use of a seq format string. )

yes!

> That looks like a bug, but printf is actually required to reject
> those two input strings.  A leading "0" means octal.

yeah, ran into that myself and thought WTF until i realised 'oh yeah. octal'.

>     $ seq 12 | xargs printf 'a-%02x-b\n'


yep, but i already knew that.

i'm not asking for help to solve a problem.  I'm submitting a wishlist
level bug report for a feature enhancement to support more of
printf's formatting capabilities in seq.


craig

-- 
craig sanders <cas@HIDDEN>




Information forwarded to bug-coreutils@HIDDEN:
bug#12482; Package coreutils. Full text available.

Message received at 12482 <at> debbugs.gnu.org:


Received: (at 12482) by debbugs.gnu.org; 21 Sep 2012 08:20:56 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Sep 21 04:20:56 2012
Received: from localhost ([127.0.0.1]:46133 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.72)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1TEyTn-0002C4-WD
	for submit <at> debbugs.gnu.org; Fri, 21 Sep 2012 04:20:56 -0400
Received: from mx.meyering.net ([88.168.87.75]:41176)
	by debbugs.gnu.org with esmtp (Exim 4.72)
	(envelope-from <jim@HIDDEN>) id 1TEyTm-0002Bu-6e
	for 12482 <at> debbugs.gnu.org; Fri, 21 Sep 2012 04:20:55 -0400
Received: from rho.meyering.net (rho.meyering.net [127.0.0.1])
	by rho.meyering.net (Acme Bit-Twister) with ESMTP id CF1E5600BC;
	Fri, 21 Sep 2012 10:19:13 +0200 (CEST)
From: Jim Meyering <jim@HIDDEN>
To: "Voelker\, Bernhard" <bernhard.voelker@HIDDEN>
Subject: Re: bug#12482: Feature Request: support for int, octal,
	and hex types in seq --format
In-Reply-To: <A75C39900FCF0B42A2CE8B26F837D2C306B4C6@HIDDEN>
	(Bernhard Voelker's message of "Fri, 21 Sep 2012 07:25:20 +0000")
References: <20120921003711.GC19332@HIDDEN>
	<A75C39900FCF0B42A2CE8B26F837D2C306B4C6@HIDDEN>
Date: Fri, 21 Sep 2012 10:19:13 +0200
Message-ID: <87wqzn94am.fsf@HIDDEN>
Lines: 89
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: -2.4 (--)
X-Debbugs-Envelope-To: 12482
Cc: "12482-done <at> debbugs.gnu.org" <12482 <at> debbugs.gnu.org>,
	Craig Sanders <cas@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.13
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -2.4 (--)

retitle 12482 RFE: seq: add support for int, octal, hex formats in --format
thanks

Voelker, Bernhard wrote:
> Craig Sanders wrote:
>
>> seq only supports floating point types like f and g in the --format string.
>>
>> Other types, including i,d,o,u,x,X would also be useful.
>>
>> e.g. "seq --format 'prefix%02isuffix' 1 50" to print zero-padded 1-50 with
>> user-specified prefix and suffix strings.
>
> IMO custom format strings for pre- or suffixing are not seq's job.

I agreed, initially.  The texinfo documentation gives examples
of how to convert seq output to hexadecimal (%x) using printf:
    --------------------
       If you want hexadecimal integer output, you can use `printf' to
    perform the conversion:

         $ printf '%x\n' `seq 1048575 1024 1050623`
         fffff
         1003ff
         1007ff

       For very long lists of numbers, use xargs to avoid system
    limitations on the length of an argument list:

         $ seq 1000000 | xargs printf '%x\n' | tail -n 3
         f423e
         f423f
         f4240

       To generate octal output, use the printf `%o' format instead of `%x'.
    --------------------

> The OP wanted a little shell solution to create 50 directories
> with a fixed prefix and suffix, so what about this?
>
>   seq -w 50 | sed 's/^/prefix/; s/$/suffix/' | xargs mkdir

Hmm...
The first time I ran an example like the above, I used -w
without realizing that there was no need, since the printf
format would handle the fixed width part.

(the disadvantage with this approach is that you have to pre-compute
the width and use that number in the printf format, whereas in Bernie's
example, that's done automatically by seq -w.  This suggests that seq's
--equal-width (-w) option *would* be handy in conjunction with the requested
integer format directives.  Then, we'd get the benefit of -w along with
the more direct use of a seq format string. )

    $ seq -w 12 | xargs printf 'a-%02x-b\n'
    a-01-b
    a-02-b
    a-03-b
    a-04-b
    a-05-b
    a-06-b
    a-07-b
    a-printf: 08: value not completely converted
    00-b
    a-printf: 09: value not completely converted
    00-b
    a-0a-b
    a-0b-b
    a-0c-b
    [Exit 123]

That looks like a bug, but printf is actually required to reject
those two input strings.  A leading "0" means octal.

This does what you want:

    $ seq 12 | xargs printf 'a-%02x-b\n'
    a-01-b
    a-02-b
    a-03-b
    a-04-b
    a-05-b
    a-06-b
    a-07-b
    a-08-b
    a-09-b
    a-0a-b
    a-0b-b
    a-0c-b




Information forwarded to bug-coreutils@HIDDEN:
bug#12482; Package coreutils. Full text available.

Message received at 12482 <at> debbugs.gnu.org:


Received: (at 12482) by debbugs.gnu.org; 21 Sep 2012 07:27:02 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Sep 21 03:27:02 2012
Received: from localhost ([127.0.0.1]:46048 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.72)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1TExde-0000xl-2c
	for submit <at> debbugs.gnu.org; Fri, 21 Sep 2012 03:27:02 -0400
Received: from senmx12-mx.siemens-enterprise.com ([62.134.46.10]:55029)
	by debbugs.gnu.org with esmtp (Exim 4.72)
	(envelope-from <bernhard.voelker@HIDDEN>)
	id 1TExda-0000xH-3b
	for 12482 <at> debbugs.gnu.org; Fri, 21 Sep 2012 03:26:59 -0400
Received: from MCHP02HTC.global-ad.net (unknown [172.29.42.235])
	by senmx12-mx.siemens-enterprise.com (Server) with ESMTP id
	4649323F05B0; Fri, 21 Sep 2012 09:25:21 +0200 (CEST)
Received: from MCHP02MSX.global-ad.net ([169.254.4.26]) by
	MCHP02HTC.global-ad.net ([172.29.42.235]) with mapi id 14.02.0318.001;
	Fri, 21 Sep 2012 09:25:20 +0200
From: "Voelker, Bernhard" <bernhard.voelker@HIDDEN>
To: Craig Sanders <cas@HIDDEN>, "12482 <at> debbugs.gnu.org"
	<12482 <at> debbugs.gnu.org>
Subject: RE: bug#12482: Feature Request: support for int, octal,	and hex
	types in seq --format
Thread-Topic: bug#12482: Feature Request: support for int, octal,	and hex
	types in seq --format
Thread-Index: AQHNl5W/il6IAniWN0yefky7HUurWJeUZMHA
Date: Fri, 21 Sep 2012 07:25:20 +0000
Message-ID: <A75C39900FCF0B42A2CE8B26F837D2C306B4C6@HIDDEN>
References: <20120921003711.GC19332@HIDDEN>
In-Reply-To: <20120921003711.GC19332@HIDDEN>
Accept-Language: de-DE, en-US
Content-Language: en-US
X-MS-Has-Attach: 
X-MS-TNEF-Correlator: 
x-originating-ip: [172.29.42.225]
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
X-Spam-Score: -2.4 (--)
X-Debbugs-Envelope-To: 12482
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.13
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -2.4 (--)

Craig Sanders wrote:

> seq only supports floating point types like f and g in the --format strin=
g.
>
> Other types, including i,d,o,u,x,X would also be useful.
>
> e.g. "seq --format 'prefix%02isuffix' 1 50" to print zero-padded 1-50 wit=
h
> user-specified prefix and suffix strings.

IMO custom format strings for pre- or suffixing are not seq's job.

The OP wanted a little shell solution to create 50 directories
with a fixed prefix and suffix, so what about this?

  seq -w 50 | sed 's/^/prefix/; s/$/suffix/' | xargs mkdir

Have a ncie day,
Berny




Information forwarded to bug-coreutils@HIDDEN:
bug#12482; Package coreutils. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 21 Sep 2012 01:05:50 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Sep 20 21:05:50 2012
Received: from localhost ([127.0.0.1]:45879 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.72)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1TErgj-0000rN-P0
	for submit <at> debbugs.gnu.org; Thu, 20 Sep 2012 21:05:50 -0400
Received: from taz.net.au ([203.16.167.1]:47001)
	by debbugs.gnu.org with esmtp (Exim 4.72)
	(envelope-from <cas@HIDDEN>) id 1TErGa-0000Fq-2H
	for submit <at> debbugs.gnu.org; Thu, 20 Sep 2012 20:38:50 -0400
Received: by taz.net.au (Postfix, from userid 1000)
	id 7607B295885C; Fri, 21 Sep 2012 10:37:11 +1000 (EST)
Date: Fri, 21 Sep 2012 10:37:11 +1000
From: Craig Sanders <cas@HIDDEN>
To: submit <at> debbugs.gnu.org
Subject: Feature Request: support for int, octal, and hex types in seq --format
Message-ID: <20120921003711.GC19332@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
User-Agent: Mutt/1.5.21 (2010-09-15)
X-Spam-Score: -4.7 (----)
X-Debbugs-Envelope-To: submit
X-Mailman-Approved-At: Thu, 20 Sep 2012 21:05:48 -0400
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.13
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -4.7 (----)

Package: Coreutils
Severity: wishlist

seq only supports floating point types like f and g in the --format string.

Other types, including i,d,o,u,x,X would also be useful.

e.g. "seq --format 'prefix%02isuffix' 1 50" to print zero-padded 1-50 with
user-specified prefix and suffix strings.

see
http://unix.stackexchange.com/questions/48750/creating-numerous-directories-using-mkdir/48758#48758
for a real-world usage example.


Thanks,

craig

-- 
craig sanders <cas@HIDDEN>




Acknowledgement sent to Craig Sanders <cas@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-coreutils@HIDDEN. Full text available.
Report forwarded to bug-coreutils@HIDDEN:
bug#12482; Package coreutils. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Mon, 25 Nov 2019 12:00:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.