Replace US numbers with European numbers


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Replace US numbers with European numbers
# 1  
Old 02-26-2010
Replace US numbers with European numbers

hey,

I have a file with numbers in US notation (1,000,000.00) as well as european notation (1.000.000,00)

i want all the numbers to be in european notation.
the numbers are in a text file, so to prevent that the regex also changes the commas in a sentence/text i thought of:
Code:
sed 's/[0-9],[0-9]/\./'

so that it only takes commas that are in between numbers. but how do i make sure it only replaces the comma, and not the entire number? because with the regex given above it replaces the entire number with a dot.


Second question: how do i make sure 1,000,000.00 becomes 1.000.000,00 instead of 1.000.000.00 ?

Last edited by Yogesh Sawant; 02-26-2010 at 12:46 PM.. Reason: added code tags
# 2  
Old 02-26-2010
Tools what about?

Code:
echo 1,000,000.00 | sed 's/\./~/' | sed 's/\,/\./g' | sed 's/~/\,/'

when switching two characters, need to change first to a third (in this case the ~), and then continue with the switching, and finally switch that ~ to where it ultimately needs to be.
# 3  
Old 02-26-2010
Try this.:

Code:
echo 1,000,000.00 | tr ',.' '.,'

 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

sed to replace / between the two numbers

i Have a file as following view pz19a0c0/1000T_J_3MoDw9DSLh1ZsCubdua-LKOQmbtiVgkIsiMbSiwF467?sessionId=15451401994597121249 view pz19a0c0/100086X67pR0MwzWnhhSO6sAEoxeFMyhh-IIbUCCdxicaQM4FC9?sessionId=154514019945971212494898 view/cart ... (5 Replies)
Discussion started by: Raghuram717
5 Replies

2. UNIX for Beginners Questions & Answers

Decimal numbers and letters in the same collums: round numbers

Hi! I found and then adapt the code for my pipeline... awk -F"," -vOFS="," '{printf "%0.2f %0.f\n",$2,$4}' xxx > yyy I add -F"," -vOFS="," (for input and output as csv file) and I change the columns and the number of decimal... It works but I have also some problems... here my columns ... (7 Replies)
Discussion started by: echo manolis
7 Replies

3. UNIX for Dummies Questions & Answers

Print numbers and associated text belonging to an interval of numbers

##### (0 Replies)
Discussion started by: lucasvs
0 Replies

4. Shell Programming and Scripting

replace numbers in records

hello every one I have file with following records begin ASX120016719 ASX190006729 ASX153406729 ASX190406759 ASX180006739 end for each record there is ASX word then 9 digits after it (NO spaces included) what i want is to : 1- skip ASX 2-skip first 2 digits after ASX word... (16 Replies)
Discussion started by: neemoze
16 Replies

5. Shell Programming and Scripting

find all numbers > x and replace with y within a file

How would I do this? How could i use <> symbols for numbers in the find/replace code below? perl -pi -e 's/test/tst/' OR is there a better way? 100 5000 2 432 4 2 33 4 5 6 65 300 301 needs to be: 100 300 2 300 4 2 33 4 5 6 65 300 300 also it might not always need spaces... i... (12 Replies)
Discussion started by: herot
12 Replies

6. Shell Programming and Scripting

the smallest number from 90% of highest numbers from all numbers in file

Hello All, I am having problem to find what is the smallest number from 90% of highest numbers from all numbers in file. I am having file with thousands of lines and hundreds of columns. I am familiar mainly with bash but I am open to whatever suggestion witch will lead to the solutions. If I... (11 Replies)
Discussion started by: Apfik
11 Replies

7. Shell Programming and Scripting

How to replace multiple numbers?

hello everyone i searched the net and i could not find script for this request. i believe sed command will do it but i'm not sure about how. my file contains thousands of records, the following is sample: BEGIN ASX15001 BEGIN ASX15000000500020101230 ASX18001020070002010123... (10 Replies)
Discussion started by: neemoze
10 Replies

8. Shell Programming and Scripting

Perl - replace repeating numbers with 0

I have a text file that looks like this: Line1) 2000001 12 34 42.5 122 204 2000001 -2000001 15 Line2) 2000001 14 2000001 38.3 2000001 88 2000001 Line3) 45 2000001 446 2000001 88 2000001 Line4) 2000001 2000001 65 883 2000001 34 2000001 5000 2000001 . . . What I want to do is to scan each... (4 Replies)
Discussion started by: xchen89x
4 Replies

9. Shell Programming and Scripting

read numbers from file and output which numbers belongs to which range

Howdy experts, We have some ranges of number which belongs to particual group as below. GroupNo StartRange EndRange Group0125 935300 935399 Group2006 935400 935476 937430 937459 Group0324 935477 935549 ... (6 Replies)
Discussion started by: thepurple
6 Replies

10. UNIX for Dummies Questions & Answers

seperating records with numbers from a set of numbers

I have two files one (numbers file)contains the numbers(approximately 30000) and the other file(record file) contains the records(approximately 40000)which may or may not contain the numbers from that file. I want to seperate the records which has the field 1=(any of the number from numbers... (15 Replies)
Discussion started by: Shiv@jad
15 Replies
Login or Register to Ask a Question