- 论坛徽章:
- 145
|
bug issue ...
$ echo 123456789.12 |sed -r ':a;/^.{1,3},/b;s/...[.,]/,&/;ta'
123,456,789.12
$ echo 123456 |sed -r ':a;/^.{1,3},/b;s/...[.,]/,&/;ta'
123456
$ echo 123456 | perl -pe '@F=split(/\./);$F[0]=~s/(?<=\d)(?=(\d{3})+\b)/,/g;$_=join(q(.),@F)'
123,456
$ echo 00123456 | perl -pe '@F=split(/\./);$F[0]=~s/(?<=\d)(?=(\d{3})+\b)/,/g;$_=join(q(.),@F)'
00,123,456
$ echo 123456 | awk -F "" 'BEGIN{flag=1}{for(i=1;i<=NF;i++){printf $i;if(flag<=2){if(i%3==0){printf ",";flag+=1}}}printf "\n"}'
123,456,
$ echo 00123456 | awk -F "" 'BEGIN{flag=1}{for(i=1;i<=NF;i++){printf $i;if(flag<=2){if(i%3==0){printf ",";flag+=1}}}printf "\n"}'
001,234,56
$ echo 012345600 | awk '{printf("%\x27.2f\n",$1)}'
12,345,600.00
|
|