Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sed awk substring challenge 2

Status
Not open for further replies.

GROKING

Programmer
Mar 8, 2005
26
US

Hello,
I have an input file like this
1, "1,123", 10, 5

I need to remove the comma , which is between the double quotes so the data appears like "123", and newline looks like this
1, "123", 10, 5

any ideas??
thanks for the help!
 
This should do the trick:

Code:
echo '1, "1,123", 10, 5, "3,123,234"' | sed '
        :a
        s/\("[0-9]*\),\([0-9,]*"\)/\1\2/g
        ta
'

ta causes it to branch back to label "a" (defined by :a) if the search and replace was successful. This is to ensure that numbers in the millions (i.e. multiple commas) are handled properly by repeating the replacement.

Annihilannic.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top