I have a file with the lines looking similar to:
"somestring": "20.000",
I want to remove the quotes around 20.000.
Other use cases are
"somestring": "20",
"somestring": "blahhhah 3",
"somestring": "",
which should give
"somestring": 20,
"somestring": "blahhhah 3",
"somestring": "",
Obvious regex to recognize numbers is [0-9]+ and [0-9].[0-9]+ for decimals.
I was told this is possible with the sed command as it can backreference, however I do not know how to use the sed command.
Can someone please provide me with any linux command to accomplish this?
$ sed -r 's@"([0-9]+(\.[0-9]+)?)",\s*$@\1,@' file
"somestring": 20.000,
"somestring": 20,
"somestring": "blahhhah 3",
"somestring": "",
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With