tags:

views:

103

answers:

4

hi...

how to change number format

from XXXXXX.XXX to XXXXXX,XXX

using sed

thaks

+2  A: 

you could do this:

$ echo "XXX.XX" | sed s/\\./,/g

ps: wouldn't that question fit better on superuser.com?

Rock
A: 

I think

s/\./,/g

should serve what u want... unless u want something more special...

Adrian Shum
A: 

Since the question is also tagged awk:

awk 'gsub(/\./,",")||1'
schot
don't have to use ||1, `awk 'gsub(/\./,",")`
ghostdog74
@ghostdog74 `gsub` returns the number of replacements, your version skips lines that do not contain at least one dot. I don't know enough about the OP's input data to omit the `||1`.
schot
+1  A: 

if you have bash/ksh etc

var=XXX.XXX
echo ${var/./,}
ghostdog74
Nice, here is a more cumbersome one that works in all POSIX shells: `var=XXX.XXX; echo ${var%.*},${var##*.}`
schot