{"id":2475,"date":"2009-10-28T17:37:54","date_gmt":"2009-10-28T22:37:54","guid":{"rendered":"http:\/\/blogs.terrorware.com\/geoff\/?p=2475"},"modified":"2013-03-29T01:35:09","modified_gmt":"2013-03-29T06:35:09","slug":"drush-search-and-replace","status":"publish","type":"post","link":"http:\/\/blogs.terrorware.com\/geoff\/2009\/10\/28\/drush-search-and-replace\/","title":{"rendered":"Node body search and replace Drush command"},"content":{"rendered":"<p>This is a command for the very useful <a href=\"http:\/\/drupal.org\/project\/drush\">Drupal Shell (Drush)<\/a> 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 <a href=\"http:\/\/www.crl.edu\">Center for Research Library&#8217;s web site<\/a><a href=\"http:\/\/blogs.terrorware.com\/geoff\/files\/2009\/10\/replace.drush.inc\">r<\/a> 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.<\/p>\n<p><a href=\"http:\/\/cvs.drupal.org\/viewvc.py\/drupal\/contributions\/modules\/drush\/README.txt?view=markup\">Install this command as you would any other contributed command<\/a> (for instance, you could put this file in your ~\/.drush folder)<\/p>\n<p>To learn how to use, check out the help text for the command by running <em>drush help replace<\/em> at the command line.<\/p>\n<p>Example usage:<\/p>\n<blockquote><p>$ drush &#8211;url=http:\/\/www.crl.edu replace jstor-titles\/economics-titles &#8220;\/http:\\\/\\\/www.crl.edu\\\/jstortitles\\\/&#8221; &#8220;&#8221;<\/p><\/blockquote>\n<p>This replaces all instances of http:\/\/www.crl.edu\/jstortitles with an empty string.  Note that the syntax and escaping of the regular expressions are for those of PHP&#8217;s <a href=\"http:\/\/php.net\/manual\/en\/function.preg-replace.php\">preg_replace<\/a> function.<\/p>\n<p><a href=\"..\/files\/2009\/10\/replace.drush.inc\">Download replace.drush<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>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&#8217;s web siter and got tired of having to visit a URL, click&hellip; <a class=\"more-link\" href=\"http:\/\/blogs.terrorware.com\/geoff\/2009\/10\/28\/drush-search-and-replace\/\">Continue reading <span class=\"screen-reader-text\">Node body search and replace Drush command<\/span><\/a><\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[20659],"tags":[263],"class_list":["post-2475","post","type-post","status-publish","format-standard","hentry","category-code","tag-drupal","entry"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p4wnIz-DV","_links":{"self":[{"href":"http:\/\/blogs.terrorware.com\/geoff\/wp-json\/wp\/v2\/posts\/2475","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/blogs.terrorware.com\/geoff\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/blogs.terrorware.com\/geoff\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/blogs.terrorware.com\/geoff\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"http:\/\/blogs.terrorware.com\/geoff\/wp-json\/wp\/v2\/comments?post=2475"}],"version-history":[{"count":4,"href":"http:\/\/blogs.terrorware.com\/geoff\/wp-json\/wp\/v2\/posts\/2475\/revisions"}],"predecessor-version":[{"id":2489,"href":"http:\/\/blogs.terrorware.com\/geoff\/wp-json\/wp\/v2\/posts\/2475\/revisions\/2489"}],"wp:attachment":[{"href":"http:\/\/blogs.terrorware.com\/geoff\/wp-json\/wp\/v2\/media?parent=2475"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/blogs.terrorware.com\/geoff\/wp-json\/wp\/v2\/categories?post=2475"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/blogs.terrorware.com\/geoff\/wp-json\/wp\/v2\/tags?post=2475"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}