[geeks] search and replace
ross-sunhelp at lonsteins.com
Fri Sep 5 13:46:26 CDT 2003
On Fri, Sep 05, 2003 at 01:27:26PM -0500, Joshua D. Boyd wrote:
> On Fri, Sep 05, 2003 at 02:04:47PM -0400, Kurt Huhn wrote:
> > sed s/pic.gif/"images/pic.gif"/g
> > will probably get you there. Unless I've typo'd something, that is....
> That takes care of one file you still have to apply it to all of them.
Off the top of my head, do all .html files, make backup...
perl -i.bak -npe 's|pic.gif|images/pic.gif|g;' /path/to/files/*.html
Same but for common images with alphanumeric names...
perl -i.bak -npe 's|(\w.(gif|jpg))|images/$1|g' /path/to/files/*.html
That's probably too crude and you'll want a better regex, maybe more like:
s|<img src=\"(\w.(gif|jpg))\"|<img src=\"images/$1\"|g
More information about the geeks