[ale] sed and massively editing files.
Pete Hardie
pete.hardie at gmail.com
Mon Nov 13 09:54:41 EST 2006
On 11/13/06, Michael B. Trausch <fd0man at gmail.com> wrote:
>
> I am pretty sure that sed is the tool for what I want to do, but I can't
> be sure. I have it doing everything else that I need. The lines that I
> have are from a ZIP code database in SQL, but I need to make some formatting
> fixups to the entire thing (42,320 lines).
>
> Each line is like this:
>
> INSERT INTO zip_summary (zip, city, state, county, area_codes, city_type,
> latitude, longitude, time_zone, county_fips, observes_dst) VALUES ('10452',
> 'Bronx', 'NY', 'Bronx', '{'347', '646', '718'}', 'P', 40.838324, -
> 73.921892, '-0500', '005', TRUE);
>
> Now, what I need to do is convert the ' characters to be " characters, but
> only inside of {...} (where the area code list is). I can't seem to
> figure out how to do that, though, because if I use a s/.../...expression, it would replace the entire thing, which isn't what I want. Is
> there a regex that will say "Match an apostrophe if between squiggly
> brackets" so that I can replace each occurrence with a quotation mark?
>
You might need to multi-step the process - use sed to split the existing
lines at the {}, and have the s/{.*'/\"/g, and then use sed to
pull the lines pack together at the {}
--
Pete Hardie
--------
Better Living Through Bitmaps
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Ale
mailing list