GNU bug report logs -
#20767
seq: support multiple % in -f format
Previous Next
Full log
View this message in rfc822 format
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.