{"id":12410311,"date":"2020-02-07T14:32:51","date_gmt":"2020-02-07T14:32:51","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/wp-cli-search-replace-scripting\/"},"modified":"2020-02-07T14:55:19","modified_gmt":"2020-02-07T14:55:19","slug":"wp-cli-search-replace-scripting","status":"publish","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/wp-cli-search-replace-scripting\/","title":{"rendered":"wp cli search-replace scripting"},"content":{"rendered":"<p>I have a bash script that runs a search-replace on every table in my WordPress installation. It works fine, but I would like to get more specific information of the changes. <\/p>\n<p>This is part of my bash script:<\/p>\n<pre><code>SITE_LIST=site_list.csv\nOLDIFS=$IFS\nIFS=,\nwhile read ID URL UPDATED CREATED\ndo\n  wp --allow-root --url=$URL search-replace $OLD $NEW\ndone &lt; $SITE_LIST\nIFS=$OLDIFS<\/code><\/pre>\n<p>I used the &#8211;log option and it worked as expected, but the log was 30MB, and not easy to parse the data of what changed.<\/p>\n<p>Ideally, I would like to capture the following two bold lines from each wp search replace command as it&#8217;s run.<\/p>\n<p>wp &#8211;allow-root &#8211;url=$URL search-replace $OLD $NEW wp_1_options<\/p>\n<pre><code>+--------------+--------------+--------------+------+\n| Table        | Column       | Replacements | Type |\n+--------------+--------------+--------------+------+\n| wp_1_options | option_name  | 0            | SQL  |\n&lt;strong&gt;| wp_1_options | option_value | 1            | PHP  |&lt;\/strong&gt;\n| wp_1_options | autoload     | 0            | SQL  |\n+--------------+--------------+--------------+------+\n&lt;strong&gt;Success: Made 1 replacement.&lt;\/strong&gt;<\/code><\/pre>\n<p>Is something like this possible?<\/p>\n","protected":false},"template":"","class_list":["post-12410311","topic","type-topic","status-publish","hentry","topic-tag-multisite","topic-tag-scripting"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/12410311","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":1,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/12410311\/revisions"}],"predecessor-version":[{"id":12410407,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/12410311\/revisions\/12410407"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=12410311"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}