Find word/pattern/string in txt/xml-file and add incremental number



I'm using Textwrangler who falls short when it comes to adding numbers to replacements. I have an xml-file with several strings containg the words:


generatoritem id="Outline Text"


I need to add an incrementing number at the end of each substitution, like so:


generatoritem id="Outline Text1"


So I need to replace 'Outline Text' with 'Outline Text' and an incrementing number.


I found an answer on a similar question and tried to type in this in textwrangler and hit Check Syntax:



perl -ple 's/"Outline Text"/$n++/e' /path/of/file.xml


Plenty of errors.. So I need to be explained this nice one liner. Or perhaps get a new one or a Python script?


No comments:

Post a Comment