Example:
Want to search all files for the string "http://www.example.com" and replace that string with "http://www.widgets.com"
Are there any scripts floating around to do this for me? I'm aware of the regexp commands etc, but I need to be able to just input a string and replacement and push go..
This is going to be used to replace URLs, so it must be capable of dealing with special characters such as: ":/.-'>< and spaces.
yourprompt> perl -pi.bak -e s#http://.*?/##g `find . -name "*.html"` the above strips out all the occurences of the [domain.com...] on all the files ending in .html and makes a backup file with the .bak extension...
this should get you started. google perl one liners find replace or something similar.
HTH,
kpaul
Still think I need a script where I can input regular text without worrying about special characters though, since my strings are going to change all the time.
Any ideas where to find a script that does this? Maybe one that I can upload to my server and change the string and replacement each time and it will do commands and special character replacements for me? Is this even possible?
if nothing else, if wouldn't be too hard to write and would be a great learning experience ;)
basically:
1) read directory
2) open files, one by one
3) user regex on each line of each file
there's more than one way to do it with Perl,
-kpaul