I have a line :
CITY;+41119;-754831
I want to divide the two numbers by 10000 to get this line :
CITY;4.1119;-75.4831
I've tried the following sed command but it does nothing, what's wrong ?
sed 's/(.*;.*)([0-9]{4};.*)([0-9]{4})/\1\.\2\.\3/g'
awk
is better tool for performing floating point arithmetic
:
x='CITY;+41119;754831'
awk -F';' -v d=10000 '{print $1,($2/d),($3/d)}' OFS=';' <<< "$x"
CITY;4.1119;75.4831
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments