Recursively replace URLs in multiple text files

There used to be a nifty little utility I used for this kind of thing, but the below works just as well:

find ./ -type f | xargs sed -i 's|http://domain.com|../relative/path/or/whatever|g'

As with grep and other utilities, sed can take different characters to represent the division between fields. Above I used the pipe (“|”) as opposed to the standard slash found in most examples.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.