GNU bug report logs - #20767
seq: support multiple % in -f format

Previous Next

Package: coreutils;

Reported by: 積丹尼 Dan Jacobson <jidanni <at> jidanni.org>

Date: Mon, 8 Jun 2015 02:07:02 UTC

Severity: wishlist

Full log


Message #8 received at 20767 <at> debbugs.gnu.org (full text, mbox):

From: Stephane Chazelas <stephane.chazelas <at> gmail.com>
To: 積丹尼 Dan Jacobson <jidanni <at> jidanni.org>
Cc: 20767 <at> debbugs.gnu.org
Subject: Re: bug#20767: seq invocation limitations documentation
Date: Mon, 8 Jun 2015 10:09:33 +0100
2015-06-08 07:28:25 +0800, 積丹尼 Dan Jacobson:
> On (info "(coreutils) seq invocation") perhaps mention if one needs to
> use two % items, a for loop might be required,
> 
> $ for i in `seq 14484 10000 34484`; do printf %d=0x%x\\n $i $i; done
> 14484=0x3894
> 24484=0x5fa4
> 34484=0x86b4
[...]

Running several commands in sequence in a loop like that (and
storing the whole output of seq in memory) is not so good an
idea. At this point, it's probably better to use awk:

awk 'BEGIN{for (i = 14484; i <= 34484; i += 10000)
  printf "%d=0x%x\n", i, i}'

See also
https://unix.stackexchange.com/questions/169716/why-is-using-a-shell-loop-to-process-text-considered-bad-practice

Might be worth pointing out awk as a standard alternative to seq
for portability btw.

-- 
Stephane




This bug report was last modified 6 years and 237 days ago.

Previous Next


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