Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
How to do thousands grouping in zsh?
- X-seq: zsh-users 19052
- From: Han Pingtian <hanpt@xxxxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: How to do thousands grouping in zsh?
- Date: Thu, 4 Sep 2014 16:52:23 +0800
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mail-followup-to: zsh-users@xxxxxxx
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
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!
Messages sorted by:
Reverse Date,
Date,
Thread,
Author