Last Updated: February 25, 2016
·
655
· fluxsauce

Removing all comments from WordPress WXR files

Sometimes, you want to forget that people had an opinion. Or just posted a lot of spam. Either way, you're reading this because you want to get rid of comments in a WordPress WXR export.

sed -i '/<wp:comment>/,/<\/wp:comment>/d' *.xml

On OSX? The installed version of sed doesn't support -i, so you'll need an alternate version. Here's how to install it with Homebrew - http://brew.sh/ -

brew install gnu-sed --default-names

Update your .bash_profile to include gnubin in your PATH:

PATH="/usr/local/opt/gnu-sed/libexec/gnubin:$PATH"