I am trying to use sed to change the format of decimal numbers in a large CSV file before importing it into a SQLite database. They all have two decimal places, may be negative use comma as a decimal separator and are therefore escaped with double quotes. I was trying the following:
sed 's/"(-?)([:digit:]+),([:digit:]{2})"/$1$2.$3/g' input.csv > output.csv
The regex seems to work on a text editor on a sample of the file, but when running it through sed, there are no changes to the original file. What am I doing wrong?
-ris a requirement. Depending onsedversion[:digit:]may be a problem as well -[0-9]works just as well. – mikeserv Mar 15 '14 at 09:04-r, i.e. enable extended regex syntax, change[:digit:]to[[:digit:]]or[0-9]. – devnull Mar 15 '14 at 09:08-ris an illegal option. – user1608941 Mar 15 '14 at 10:11sedonly changes the original file if you use the "in-place" option-i. By default, it just prints the edited text to stdout. – n.st Mar 15 '14 at 11:14