vendredi 28 novembre 2014

How do I add something to the end of "}" if a pattern is matched?


If I have something that looks like this:



hello {sdsdsdsds} pattern {askjdasjkdjasd} hello {siadsd} pattern {iuewer}


So if pattern if matched before {*}, I need to add a ;. Output:



hello {sdsdsdsds} pattern {askjdasjkdjasd}; hello {siadsd} pattern {iuewer};


And this is just one lines, yes.


Now, I though of something like this:



's{.*}/


But I can't quite figure out how to make sed remember the contents of .*.


Then theres this,



'/pattern\ {.*}/ s/$/;/'


But this won't work since it is only one line.



Aucun commentaire:

Enregistrer un commentaire