Reputation: 5
I have a csv file with fields like so:
"231444","344","some string","222"
I have been trying, without success, to remove the double quotes from around the integers in the csv. I have tried a bit of sed, and attempted to awk/gawk but I am really having trouble with this one. Expected output would be:
231444,344,"some string",222
There are no negative integers. Any help would be much appreciated, and thank you in advance.
Upvotes: 0
Views: 2093
Reputation: 39355
Just for a reference. This things are can be done using Perl's one liner as well.
linux:
perl -i.bak -p -e 's/"(\d+)"/$1/g' input.txt
For reference, Windows(single quote doesn't work):
perl -i.bak -p -e "s/\"(\d+)\"/$1/g" input.txt
Upvotes: 3
Reputation: 39522
Your regex would be /"(\d+)"/g
which should be replaced with \1
.
Without knowing sed, I assume it'd be something like this (based on the Wikipedia example):
sed 's/"(\d+)"/\1/g' inputFileName > outputFileName
Upvotes: 3