On Tue, 29 Jul 2003, John J. Trammell wrote: > On Tue, Jul 29, 2003 at 09:04:30PM -0500, Peter Clark wrote: > > I ran wget on a large site that has all the links hardcoded. I'd like to > > remove all instances of, say, 'http://www.site.com/directory' so that I can > > view it offline and have all the links work locally. So, what would be the > > best way to recursively work through the files and remove the text? > > > (untested) > > find . -type f -print0 | xargs -0 perl -pi -e 's(http://www.site.com/directory)(my/new/dir)g' > > Or maybe you want a file pattern in the find, like: > > find . -name '*.html' -print0 | ... I use this all the time to change html links... If all the files are in 1 directory: perl -pi.bak -e 's/www.site.com/directory/g;' *.html Or if they are in subdirectories: find . -name '*.html' -exec perl -pi.bak -e 's/www.site.com/directory/g;' {} \; The .bak makes a backup copy of the original file in case you mess something up. Remove it to keep it from creating backups. (but be careful) _______________________________________________ TCLUG Mailing List - Minneapolis/St. Paul, Minnesota http://www.mn-linux.org tclug-list at mn-linux.org https://mailman.real-time.com/mailman/listinfo/tclug-list