<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" >

<channel>
	<title>spiralbound.net &#187; string</title>
	<atom:link href="http://spiralbound.net/tag/string/feed" rel="self" type="application/rss+xml" />
	<link>http://spiralbound.net</link>
	<description>my digital notebook</description>
	<lastBuildDate>Sat, 24 Jul 2010 03:47:27 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>PHP and Sed for String Substitution</title>
		<link>http://spiralbound.net/2007/12/12/php-and-sed-for-string-substitution</link>
		<comments>http://spiralbound.net/2007/12/12/php-and-sed-for-string-substitution#comments</comments>
		<pubDate>Wed, 12 Dec 2007 19:17:51 +0000</pubDate>
		<dc:creator>cliff</dc:creator>
				<category><![CDATA[Data and Technology]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[path]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[sed]]></category>
		<category><![CDATA[spaces]]></category>
		<category><![CDATA[string]]></category>
		<category><![CDATA[str_replace]]></category>
		<category><![CDATA[substitution]]></category>
		<category><![CDATA[unix]]></category>
		<category><![CDATA[unix find]]></category>

		<guid isPermaLink="false">http://spiralbound.net/2007/12/12/php-and-sed-for-string-substitution</guid>
		<description><![CDATA[I needed to replace a string in several thousand files scattered all over the filesystem on one of our servers. I used find to create a list of files that needed to be changed, along with their complete path and called it "list.txt". It looked something like this: /path/to/file/one/fileone.html /path/to/file/two/filetwo.php /path/to/file/three/filethree.htm /path/to/directory with spaces/filefour.txt and [...]]]></description>
			<content:encoded><![CDATA[<p>I needed to replace a string in several thousand files scattered all over the filesystem on one of our servers. I used find to create a list of files that needed to be changed, along with their complete path and called it "list.txt". It looked something like this:</p>
<p><code><br />
/path/to/file/one/fileone.html<br />
/path/to/file/two/filetwo.php<br />
/path/to/file/three/filethree.htm<br />
/path/to/directory with spaces/filefour.txt<br />
and so on...<br />
</code></p>
<p>I worked out the "sed" command to do the in place editing, and <a href="http://nosheep.net">Zach</a> helped me whip up a quick PHP script to read the contents of "list.txt" into an array and iterate through it. He was also nice enough to show me how to use "str_replace" to escape any annoying spaces that happened to find their way into the names of directories.</p>
<div class="igBar"><span id="lphp-2"><a href="#" onclick="javascript:showPlainTxt('php-2'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-2">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">&lt;?php</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$files</span>=<a href="http://www.php.net/file"><span style="color:#000066;">file</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'list.txt'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">foreach</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$files</span> <span style="color:#616100;">as</span> <span style="color:#0000FF;">$file</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$command</span>=<span style="color:#FF0000;">'/bin/sed -i <span style="color:#000099; font-weight:bold;">\'</span>s/old-string/new-string/g<span style="color:#000099; font-weight:bold;">\'</span> '</span>.<a href="http://www.php.net/str_replace"><span style="color:#000066;">str_replace</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">' '</span>,<span style="color:#FF0000;">'<span style="color:#000099; font-weight:bold;">\ </span>'</span>,<span style="color:#0000FF;">$file</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/exec"><span style="color:#000066;">exec</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$command</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">?&gt;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>It's a handy little script that I'm sure I will find a use for later, so I thought I would put it up here.</p>
]]></content:encoded>
			<wfw:commentRss>http://spiralbound.net/2007/12/12/php-and-sed-for-string-substitution/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Ecto is Busted in WordPress 2.1</title>
		<link>http://spiralbound.net/2007/01/30/ecto-is-busted-in-wordpress-21</link>
		<comments>http://spiralbound.net/2007/01/30/ecto-is-busted-in-wordpress-21#comments</comments>
		<pubDate>Tue, 30 Jan 2007 16:08:17 +0000</pubDate>
		<dc:creator>cliff</dc:creator>
				<category><![CDATA[Data and Technology]]></category>
		<category><![CDATA[Adriaan]]></category>
		<category><![CDATA[automattic]]></category>
		<category><![CDATA[blogging]]></category>
		<category><![CDATA[Blogs]]></category>
		<category><![CDATA[broken ecto]]></category>
		<category><![CDATA[ecto]]></category>
		<category><![CDATA[int]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[string]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[wordpress 2.1]]></category>
		<category><![CDATA[xmlrpc]]></category>
		<category><![CDATA[xmlrpc.php]]></category>

		<guid isPermaLink="false">http://spiralbound.net/2007/01/30/ecto-is-busted-in-wordpress-21/</guid>
		<description><![CDATA[Last week I took this site to WordPress 2.1 and much to my dismay realized that Ecto, my favorite XMLRPC blogging client no longer worked. It would let me post, but it was never able to update the category information for posts... It just hung with no error. I looked into it, and found out [...]]]></description>
			<content:encoded><![CDATA[<p>Last week I took this site to <a href="http://wordpress.org/development/2007/01/ella-21/">WordPress 2.1</a> and much to my dismay realized that <a href="http://ecto.kung-foo.tv/">Ecto</a>, my favorite XMLRPC blogging client no longer worked. It would let me post, but it was never able to update the category information for posts... It just hung with no error. I looked into it, and found out that <a href="http://nslog.com/2007/01/23/categoryid_in_wordpress_21_breaks_ecto/">Ecto expects the category information to be returned as a string, not an int</a>.</p>
<p><a href="http://blog.kung-foo.tv/archives/001720.html">Adriaan</a>, the developer of Ecto is <a href="http://wordpress.com/forums/topic.php?id=5922">blaming WordPress</a>, while I'm sure the folks at <a href="http://automattic.com/">Automattic</a> would call it an Ecto problem... That's just how these things tend to work. Anyhow, it's pretty easy to fix if you make <a href="http://trac.wordpress.org/attachment/ticket/3662/3662-xmlrpc-categoryId.diff">this quick change</a> to <strong>xmlrpc.php.</strong></p>
<p>Simply change this on line 180:</p>
<p><code>'categoryId' => $catid,</code></p>
<p>To this:</p>
<p><code>'categoryId' => (string) $catid,</code></p>
<p>Hopefully someone will go back to their code tree and make a permanent fix so we don't have to constantly edit this file every time we upgrade.</p>
]]></content:encoded>
			<wfw:commentRss>http://spiralbound.net/2007/01/30/ecto-is-busted-in-wordpress-21/feed</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
	</channel>
</rss>
