[kwlug-disc] sed + bash

Richard Weait richard at weait.com
Fri Apr 3 15:07:57 EDT 2009


So let's say you've got 

- an arbitrary xml file, a big one, and it has a bunch of tags with
numeric values. Like <mytag>12345</mytag>

- and then a bunch more of these big xml files also with the same
numeric tags.

And let's say, just hypothetically, that you need to make sure that
mytag values are unique amongst the collection of files.  And let's say
that going through the files and replacing the values with 1 to n is
okay, as long as they don't repeat.  

I'd think that sed might be a good way to find <mytag> in big files
without requiring them to be complete in memory.  And that a little bit
of bash could keep track of the last value for n and start from that on
the next file.  

Any thoughts on what that bash and sed invocation might look like?





More information about the kwlug-disc mailing list