Hi,
I have a variable say NUM="9.126.145.110"
I need to get the output as 9,126,145,110
I tried with sed command as sed s/\./,/ $NUM
But it didnt work
Please help..
Hi,
I have a variable say NUM="9.126.145.110"
I need to get the output as 9,126,145,110
I tried with sed command as sed s/\./,/ $NUM
But it didnt work
Please help..
sed -e's/\./,/g'
---------- Post updated at 01:03 PM ---------- Previous update was at 01:02 PM ----------
or it can be with $NUM as
echo $NUM|sed -e's/\./,/g'
echo $a | sed "s/\./,/g"
It works..
bash, ksh93:
echo ${NUM//./,}
and with the right locale:
printf "%'d\n" ${NUM//.}
--
Otherwise:
echo $NUM | sed 'y/./,/'
echo $NUM | tr . ,
You can also get rid of the pipe:
sed 'y/./,/' <<< $NUM
awk -F. '{$1=$1}1' OFS=, <<< $NUM