Multiple Search/Replace in one script?
![](https://secure.gravatar.com/avatar/e79f226aa442b589932230491affa641.jpg?s=120&d=mm&r=g)
Hi, I am looking for a way to automate (and also archive) my most common ten or twenty search/replace runs. I have to admit, I have no idea about scripting. But I guess there should be a way in Applecript/Perl/Rupy/Whatever to write down several entries with... ... what should be the search string ... what should be the replace string ... what kind of search should be opeated (regulr expression, case sensitive, etc.) Any recommendations? Steffen
![](https://secure.gravatar.com/avatar/cedc4d83943006afe3994fb0a0455f82.jpg?s=120&d=mm&r=g)
On Sat, 26 May 2007, Steffen Wolfrum wrote:
Any recommendations?
MySQL ships with the "replace" command. I use most often "sed", for example "sed s/xxx/yyy/g old-file >new-file" Cheers, Peter -- http://pmrb.free.fr/contact/
![](https://secure.gravatar.com/avatar/c5ae4f9aa0d3a9bd5376e92b322c3e50.jpg?s=120&d=mm&r=g)
On Sat, 26 May 2007, Steffen Wolfrum wrote:
Hi,
I am looking for a way to automate (and also archive) my most common ten or twenty search/replace runs.
I have to admit, I have no idea about scripting. But I guess there should be a way in Applecript/Perl/Rupy/Whatever to write down several entries with...
... what should be the search string ... what should be the replace string ... what kind of search should be opeated (regulr expression, case sensitive, etc.)
Any recommendations?
Most editors should be able to do this. I use vim, and most search replace is :s/search/replace/flags, and you can store common searches by either mapping them to keystores (F1, F2, etc, or sequence of keys) or writing functions or scripts and sourcing them. An advantage is that I can do a visual search/replace and manually confirm all changes. Sometimes this is easier than trying to figure out a regex that will take care of all cases. Aditya
participants (3)
-
Aditya Mahajan
-
Peter Münster
-
Steffen Wolfrum