I had to do this like 5 times today, so I thought I’d put it out there (so I can reference it).
Note: you might want to backup your stuff, just in case you screw up your regular expression.
Basically, I have a bunch of files that need to have changes, such as email address, or include paths.
So, for example, in one I had to change a bunch of email addresses so I used `sed`. To do this on one file you would simply run the sed command directly:
sed -e s/info@olddomain.com/info@newdomain.com/g -i file.html
-e tags the regular expression you’re using
-i means we’re editing the files inline (not outputting the results to standard out)
Don’t forget g, because this will ensure that the expression is greedy and will find all the instances of this expression.
Of course, you probably want to run this on a bunch of files, so you would use `find`, because it’s awesome:
find -name "*.html" -exec sed -e s/info@olddomain.com/info@newdomain.com/g -i {} \;
0 responses so far ↓
There are no comments yet...Kick things off by filling out the form below.