<?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/"
	>

<channel>
	<title>The efnx code blog. &#187; bash</title>
	<atom:link href="http://efnx.com/tag/bash/feed/" rel="self" type="application/rss+xml" />
	<link>http://efnx.com</link>
	<description>code. blog.</description>
	<lastBuildDate>Wed, 18 Jan 2012 20:48:11 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.3</generator>
		<item>
		<title>WordPress Auto-Update Script For A Linux Server</title>
		<link>http://efnx.com/wordpress-auto-update-script-for-a-linux-server/</link>
		<comments>http://efnx.com/wordpress-auto-update-script-for-a-linux-server/#comments</comments>
		<pubDate>Mon, 16 Mar 2009 19:09:38 +0000</pubDate>
		<dc:creator>Schell</dc:creator>
				<category><![CDATA[Shell Scripting]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://blog.efnx.com/?p=163</guid>
		<description><![CDATA[I wrote a little update script for my server to auto update my wordpress installation and figured it might help some other people as well. To use it you simply supply as arguments to the script three things: 1. the directory where your wordpress install lives 2. the name of the backups you&#8217;d like to [...]]]></description>
			<content:encoded><![CDATA[<p>I wrote a little update script for my server to auto update my wordpress installation and figured it might help some other people as well. To use it you simply supply as arguments to the script three things: </p>
<p>1. the directory where your wordpress install lives<br />
2. the name of the backups you&#8217;d like to create for that directory<br />
3. the version of the wordpress install you&#8217;d like to upgrade to</p>
<p>For example, on my server I use this command to update my wp version:</p>
<p>sudo ./updateWordpress.sh /path/to/wordpress/installation efnx 2.7.1<br />
[enter password]<br />
[watch output]</p>
<p>done!</p>
<p>Here is the code to my script:</p>
<div class="codecolorer-container bash twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;">#!/bin/bash</span><br />
<span style="color: #007800;">DIR2UPDATE</span>=<span style="color: #007800;">$1</span><br />
<span style="color: #007800;">NAME</span>=<span style="color: #007800;">$2</span><br />
<span style="color: #007800;">VERSION</span>=<span style="color: #007800;">$3</span><br />
<br />
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Beginning update of <span style="color: #007800;">$DIR2UPDATE</span> to version <span style="color: #007800;">$VERSION</span>...&quot;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-d</span> wordpress_svn <span style="color: #7a0874; font-weight: bold;">&#93;</span><br />
<span style="color: #000000; font-weight: bold;">then</span><br />
&nbsp; &nbsp; <span style="color: #007800;">day</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">date</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">cut</span> <span style="color: #660033;">-d</span><span style="color: #ff0000;">&quot; &quot;</span> -f3<span style="color: #000000; font-weight: bold;">`</span><br />
&nbsp; &nbsp; <span style="color: #007800;">tme</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">date</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">cut</span> <span style="color: #660033;">-d</span><span style="color: #ff0000;">&quot; &quot;</span> -f4<span style="color: #000000; font-weight: bold;">`</span><br />
&nbsp; &nbsp; <span style="color: #007800;">hour</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #800000;">${tme}</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">cut</span> <span style="color: #660033;">-d</span><span style="color: #ff0000;">&quot;:&quot;</span> -f1<span style="color: #000000; font-weight: bold;">`</span><br />
<br />
&nbsp; &nbsp; <span style="color: #007800;">fileday</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">ls</span> <span style="color: #660033;">-lh</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> wordpress_svn <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">cut</span> <span style="color: #660033;">-c</span> <span style="color: #000000;">37</span>-<span style="color: #000000;">39</span><span style="color: #000000; font-weight: bold;">`</span><br />
&nbsp; &nbsp; <span style="color: #007800;">filehour</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">ls</span> <span style="color: #660033;">-lh</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> wordpress_svn <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">cut</span> <span style="color: #660033;">-c</span> <span style="color: #000000;">40</span>-<span style="color: #000000;">41</span><span style="color: #000000; font-weight: bold;">`</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #800000;">${fileday}</span> <span style="color: #000000; font-weight: bold;">!</span>= <span style="color: #800000;">${day}</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;SVN directory not up to date, [ file's date <span style="color: #007800;">${fileday}</span> != today <span style="color: #007800;">${day}</span> ] deleting and updating&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-rf</span> wordpress_svn<span style="color: #000000; font-weight: bold;">/*</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #7a0874; font-weight: bold;">cd</span> wordpress_svn<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #c20cb9; font-weight: bold;">svn</span> <span style="color: #c20cb9; font-weight: bold;">co</span> http:<span style="color: #000000; font-weight: bold;">//</span>svn.automattic.com<span style="color: #000000; font-weight: bold;">/</span>wordpress<span style="color: #000000; font-weight: bold;">/</span>tags<span style="color: #000000; font-weight: bold;">/</span><span style="color: #800000;">${VERSION}</span> .<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$filehour</span>&quot;</span> <span style="color: #000000; font-weight: bold;">!</span>= <span style="color: #ff0000;">&quot;<span style="color: #007800;">$hour</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;SVN directory not up to date, [ file's hour <span style="color: #007800;">${filehour}</span> != now <span style="color: #007800;">${hour}</span> ] deleting and updating&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-rf</span> wordpress_svn<span style="color: #000000; font-weight: bold;">/*</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #7a0874; font-weight: bold;">cd</span> wordpress_svn<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #c20cb9; font-weight: bold;">svn</span> <span style="color: #c20cb9; font-weight: bold;">co</span> http:<span style="color: #000000; font-weight: bold;">//</span>svn.automattic.com<span style="color: #000000; font-weight: bold;">/</span>wordpress<span style="color: #000000; font-weight: bold;">/</span>tags<span style="color: #000000; font-weight: bold;">/</span><span style="color: #800000;">${VERSION}</span> .<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;SVN directory is up to date, skipping update&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #7a0874; font-weight: bold;">cd</span> wordpress_svn<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">fi</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">fi</span><br />
<br />
<span style="color: #000000; font-weight: bold;">else</span><br />
&nbsp; &nbsp; <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Creating new svn directory and checking out version <span style="color: #007800;">$VERSION</span>...&quot;</span>;<br />
&nbsp; &nbsp; <span style="color: #c20cb9; font-weight: bold;">mkdir</span> wordpress_svn;<br />
&nbsp; &nbsp; <span style="color: #7a0874; font-weight: bold;">cd</span> wordpress_svn;<br />
&nbsp; &nbsp; <span style="color: #c20cb9; font-weight: bold;">svn</span> <span style="color: #c20cb9; font-weight: bold;">co</span> http:<span style="color: #000000; font-weight: bold;">//</span>svn.automattic.com<span style="color: #000000; font-weight: bold;">/</span>wordpress<span style="color: #000000; font-weight: bold;">/</span>tags<span style="color: #000000; font-weight: bold;">/</span><span style="color: #800000;">${VERSION}</span> .;<br />
<span style="color: #000000; font-weight: bold;">fi</span><br />
<br />
<span style="color: #7a0874; font-weight: bold;">cd</span> ..<br />
<br />
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-d</span> wordpress_int <span style="color: #7a0874; font-weight: bold;">&#93;</span><br />
<span style="color: #000000; font-weight: bold;">then</span><br />
&nbsp; &nbsp; <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Removing old intermediate container...&quot;</span>;<br />
&nbsp; &nbsp; <span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-rf</span> wordpress_int;<br />
<span style="color: #000000; font-weight: bold;">fi</span><br />
<br />
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Creating new intermediate container...&quot;</span><br />
<span style="color: #c20cb9; font-weight: bold;">mkdir</span> wordpress_int<br />
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Moving version <span style="color: #007800;">$VERSION</span> files into intermediate container...&quot;</span><br />
<span style="color: #c20cb9; font-weight: bold;">cp</span> <span style="color: #660033;">-rpf</span> wordpress_svn<span style="color: #000000; font-weight: bold;">/*</span> wordpress_int<br />
<br />
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Moving config and custom files from <span style="color: #007800;">$NAME</span> into intermediate container...&quot;</span><br />
<br />
<span style="color: #c20cb9; font-weight: bold;">cp</span> <span style="color: #660033;">-p</span> <span style="color: #800000;">${DIR2UPDATE}</span><span style="color: #000000; font-weight: bold;">/</span>wp-config.php wordpress_int<br />
<span style="color: #c20cb9; font-weight: bold;">cp</span> <span style="color: #660033;">-rpf</span> <span style="color: #800000;">${DIR2UPDATE}</span><span style="color: #000000; font-weight: bold;">/</span>wp-content<span style="color: #000000; font-weight: bold;">/*</span> wordpress_int<span style="color: #000000; font-weight: bold;">/</span>wp-content<span style="color: #000000; font-weight: bold;">/</span><br />
<span style="color: #c20cb9; font-weight: bold;">cp</span> <span style="color: #660033;">-p</span> <span style="color: #800000;">${DIR2UPDATE}</span><span style="color: #000000; font-weight: bold;">/</span>.htaccess wordpress_int<br />
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">'Updating svn for wp-content'</span><br />
<span style="color: #c20cb9; font-weight: bold;">svn</span> update wordpress_int<br />
<br />
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Backing up <span style="color: #007800;">$DIR2UPDATE</span>...&quot;</span><br />
<span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #800000;">${NAME}</span>_backup<br />
<span style="color: #666666; font-style: italic;">#mv -f ${DIR2UPDATE}/* ${NAME}_backup &nbsp; # if you'd like to mv instead of cp</span><br />
<span style="color: #c20cb9; font-weight: bold;">cp</span> <span style="color: #660033;">-rpf</span> <span style="color: #800000;">${DIR2UPDATE}</span><span style="color: #000000; font-weight: bold;">/*</span> <span style="color: #800000;">${NAME}</span>_backup<br />
<span style="color: #c20cb9; font-weight: bold;">tar</span> <span style="color: #660033;">-czvf</span> <span style="color: #800000;">${NAME}</span>_backup.tar.gz <span style="color: #800000;">${NAME}</span>_backup<br />
<span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-rf</span> <span style="color: #800000;">${NAME}</span>_backup<br />
<br />
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">'Removing svn data from intermediate container...'</span> <br />
<span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-rf</span> <span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">find</span> wordpress_int<span style="color: #000000; font-weight: bold;">/</span> <span style="color: #660033;">-type</span> d <span style="color: #660033;">-name</span> .svn<span style="color: #000000; font-weight: bold;">`</span><br />
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Moving intermediate container contents to <span style="color: #007800;">$DIR2UPDATE</span>...&quot;</span><br />
<span style="color: #c20cb9; font-weight: bold;">cp</span> <span style="color: #660033;">-rpf</span> wordpress_int<span style="color: #000000; font-weight: bold;">/*</span> <span style="color: #800000;">${DIR2UPDATE}</span></div></div>
<p>Or you can just download the script here [rightclick + 'save as']-><br />
<a href='http://blog.efnx.com/wp-content/uploads/2009/03/updatewordpress.sh'>updateWordpress.sh</a></p>
]]></content:encoded>
			<wfw:commentRss>http://efnx.com/wordpress-auto-update-script-for-a-linux-server/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Auto Comment Block In TextMate</title>
		<link>http://efnx.com/auto-comment-block-in-textmate/</link>
		<comments>http://efnx.com/auto-comment-block-in-textmate/#comments</comments>
		<pubDate>Mon, 21 Jan 2008 09:34:14 +0000</pubDate>
		<dc:creator>Schell</dc:creator>
				<category><![CDATA[Shell Scripting]]></category>
		<category><![CDATA[auto-comment]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[TextMate]]></category>

		<guid isPermaLink="false">http://blog.efnx.com/?p=43</guid>
		<description><![CDATA[If you haven&#8217;t heard of TextMate go check it out it&#8217;s sweet. It allows a helluva lot of automation and is damn near the only thing you need for development of any language [minus compilers]. I&#8217;m about ready to throw away my Flash CS3 IDE I got for free from my day job and shell [...]]]></description>
			<content:encoded><![CDATA[<p>If you haven&#8217;t heard of TextMate go check it out <a href="http://macromates.com/">it&#8217;s sweet</a>. It allows a helluva lot of automation and is damn near the only thing you need for development of any language [minus compilers]. I&#8217;m about ready to throw away my Flash CS3 IDE I got for free from my day job and shell out the 39 pounds to buy it [those of you who know me personally know I don't ever buy software]. </p>
<p>So, here&#8217;s a little command I wrote in the form of a bash script [I think all textmate commands are bash scripts or cocoadialog thangs]. The script takes selected input and pads it with &#8220;/* */&#8221; if it isn&#8217;t already, effectively commenting the text or it strips the comment block. I don&#8217;t write shell scripts often, so I like it when I get one that&#8217;s really useful.</p>
<div class="codecolorer-container bash twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;">#!/bin/bash</span><br />
<br />
<span style="color: #666666; font-style: italic;">#-------------------------------------------------------------------------</span><br />
<span style="color: #666666; font-style: italic;"># Make comment / Undo comment</span><br />
<span style="color: #666666; font-style: italic;"># by Schell Scivally</span><br />
<span style="color: #666666; font-style: italic;"># @ efnx.com</span><br />
<span style="color: #666666; font-style: italic;">#-------------------------------------------------------------------------</span><br />
<br />
<span style="color: #007800;">opening</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$TM_SELECTED_TEXT</span>&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'BEGIN {nlines=0} /\/\*/ {nlines++} END {print nlines}'</span><span style="color: #000000; font-weight: bold;">`</span><br />
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$opening</span>&quot;</span> == <span style="color: #000000;">0</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>;<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">then</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;/*<span style="color: #007800;">$TM_SELECTED_TEXT</span>*/&quot;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #007800;">output</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$TM_SELECTED_TEXT</span>&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #ff0000;">'s/\*\///g'</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #ff0000;">'s/\/\*//g'</span><span style="color: #000000; font-weight: bold;">`</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$output</span>&quot;</span><br />
<span style="color: #000000; font-weight: bold;">fi</span></div></div>
]]></content:encoded>
			<wfw:commentRss>http://efnx.com/auto-comment-block-in-textmate/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

