给数字加逗号


使用shell给数字加逗号,如“2384034803”变成“2,384,034,803”,大家都有什么方法,越简单越好

趣味 shell

dydng 12 years, 4 months ago

试试printf

   
  printf "%'d\n" 123456789
  
printf "%'d\n" 238403480455689

[root@sg-203 ~]# printf "%'d\n" 123456789
123,456,789
[root@sg-203 ~]# printf "%'d\n" 238403480455689
238,403,480,455,689

领域爱好者 answered 12 years, 4 months ago

Your Answer