2

I am migrating my blog, and all the posts have metadata at the top of the file. As a result I have a group of nearly 100 files in a directory where I want to do a search and replace for:

^permalink: http://blog.olddomain.com/(.*)$

to

permalink: http://blog.newdomain.com/$1

in all 100 files.

What commands would I use to do this?

3

sed is often used to pipe something through it, but it can process files just as well and, with the -i option, can even change them in place.

sed -i 's|^\(permalink: http://blog\.\)olddomain\(\.com/.*\)$|\1newdomain\2|g' <shell-glob-pattern>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.