Node body search and replace Drush command

This is a command for the very useful Drupal Shell (Drush) module that lets you search and replace text in the body of a node using regular expressions. I wrote it when I was fixing broken links for the Center for Research Library’s web siter and got tired of having to visit a URL, click the edit link, replace the text, update the revision log, and click the save button.

Install this command as you would any other contributed command (for instance, you could put this file in your ~/.drush folder)

To learn how to use, check out the help text for the command by running drush help replace at the command line.

Example usage:

$ drush –url= replace jstor-titles/economics-titles “/http:\/\/\/jstortitles\/” “”

This replaces all instances of with an empty string. Note that the syntax and escaping of the regular expressions are for those of PHP’s preg_replace function.

Download replace.drush