Reputation: 1283
I have a file like:
35.26660,129.0373,'207636');
35.26667,129.0375,'207636');
35.55555,129.0377,'207636');
I want to delete last number between single quotes and the corresponding comma. I want the result to be like:
35.26660,129.0373);
35.26667,129.0375);
35.55555,129.0377);
I tried to use sed, but I made a mistake and I cannot see what is the problem. If I use command:
sed "s/'//g"
Then I delete only the quotes
If I use command:
sed "s/[0-9]//g"
Then I delete only number between single quotes.
Update #1:
Sorry, in few lines I have a more data like:
'abc', '123' 35.26660,129.0373,'207636');
Upvotes: 0
Views: 69
Reputation: 41446
Using awk
awk -F\' '{$2="";sub(/, +/,"")}1' file
35.26660,129.0373);
35.26667,129.0375);
35.55555,129.0377);
Upvotes: 0
Reputation: 784958
You can use this sed:
sed -i.bak "s/,'[^']*'//" file
It gives:
35.26660,129.0373);
35.26667,129.0375);
35.55555,129.0377);
Upvotes: 3