[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#20767: seq invocation limitations documentation
From: |
Stephane Chazelas |
Subject: |
bug#20767: seq invocation limitations documentation |
Date: |
Mon, 8 Jun 2015 10:09:33 +0100 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
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