* How to do thousands grouping in zsh?
@ 2014-09-04 8:52 Han Pingtian
2014-09-04 9:44 ` Peter Stephenson
0 siblings, 1 reply; 2+ messages in thread
From: Han Pingtian @ 2014-09-04 8:52 UTC (permalink / raw)
To: zsh-users
Hello,
Looks like builtin printf doesn't support "'" flag. I try to figure out
a method to do the thousands grouping of numbers. It works fine.
num_group()
{
local a
local i
a=(${(s::)1})
i=$((${#a}/3))
for ((;i>0;i--))
do
if [[ -n $a[-i*3-1] ]]
then
a[-i*3]=(, $a[-i*3])
fi
done
print ${(j::)a}
}
Is there any other method?
Thanks in advance!
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-09-04 9:44 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-04 8:52 How to do thousands grouping in zsh? Han Pingtian
2014-09-04 9:44 ` Peter Stephenson
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).