<?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:series="http://unfoldingneurons.com/"
	>

<channel>
	<title>Brock Angelo &#187; Bash</title>
	<atom:link href="http://brockangelo.com/category/code/bash-programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://brockangelo.com</link>
	<description>cool little projects</description>
	<lastBuildDate>Wed, 01 Sep 2010 17:07:39 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>How to Display Your &#8220;Uptime&#8221; using Bash</title>
		<link>http://brockangelo.com/2009/06/05/how-to-display-your-uptime-using-bash/</link>
		<comments>http://brockangelo.com/2009/06/05/how-to-display-your-uptime-using-bash/#comments</comments>
		<pubDate>Fri, 05 Jun 2009 11:30:39 +0000</pubDate>
		<dc:creator>brockangelo</dc:creator>
				<category><![CDATA[Bash]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[scripts]]></category>
		<category><![CDATA[uptime]]></category>

		<guid isPermaLink="false">http://brockangelo.com/?p=879</guid>
		<description><![CDATA[Bash is a powerful scripting tool and comes in handy on more than one occasion. Here is a fun one: Write your server uptime to a text file so that you can display it on a webpage.


Related posts:<ol><li><a href='http://brockangelo.com/2009/06/07/display-the-contents-of-a-file-using-php/' rel='bookmark' title='Permanent Link: Display the Contents of a File Using PHP'>Display the Contents of a File Using PHP</a></li><li><a href='http://brockangelo.com/2010/02/03/april-fools-batch-file/' rel='bookmark' title='Permanent Link: April Fool&#8217;s Batch File'>April Fool&#8217;s Batch File</a></li><li><a href='http://brockangelo.com/2008/09/13/display-novell-servers-connected-to-your-server/' rel='bookmark' title='Permanent Link: Display Novell Servers Connected to Your Server'>Display Novell Servers Connected to Your Server</a></li></ol>]]></description>
			<content:encoded><![CDATA[<p>Bash is a powerful scripting tool and comes in handy on more than one occasion. Here is a fun one: Write your server uptime to a text file so that you can display it on a webpage.</p>
<pre class="brush: bash;">
#!/bin/sh

# get the uptime data
days=$(uptime | awk '{print $3}' | sed 's/,//g')
hours=$(uptime | awk '{print $5}' | sed 's/,//g')
label=$(uptime | awk '{print $4}')

if [ &quot;$days&quot; = 1 ]; then
day_label='day'
else
day_label='days'
fi

#format labels
if [ $hours = 1 ]; then
hour_label='hour'
else
hour_label='hours'
fi

#format output
if [ &quot;$label&quot; = 'mins,' ]; then
echo 'This server has been on for '$days minutes'' &gt; /var/www/uptime.txt
elif [[ &quot;$label&quot; = 'day,' || &quot;$label&quot; = 'days,' ]]; then
echo 'This server has been on for '$days $day_label, $hours $hour_label'' &gt; /var/www/uptime.txt
elif [ &quot;$label&quot; = '2' ]; then
echo 'This server has been on for '$days hours'' &gt; /var/www/uptime.txt
fi
</pre>


<p>Related posts:<ol><li><a href='http://brockangelo.com/2009/06/07/display-the-contents-of-a-file-using-php/' rel='bookmark' title='Permanent Link: Display the Contents of a File Using PHP'>Display the Contents of a File Using PHP</a></li><li><a href='http://brockangelo.com/2010/02/03/april-fools-batch-file/' rel='bookmark' title='Permanent Link: April Fool&#8217;s Batch File'>April Fool&#8217;s Batch File</a></li><li><a href='http://brockangelo.com/2008/09/13/display-novell-servers-connected-to-your-server/' rel='bookmark' title='Permanent Link: Display Novell Servers Connected to Your Server'>Display Novell Servers Connected to Your Server</a></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://brockangelo.com/2009/06/05/how-to-display-your-uptime-using-bash/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>My Top 10 Ubuntu Aliases</title>
		<link>http://brockangelo.com/2009/05/30/my-top-10-ubuntu-aliases/</link>
		<comments>http://brockangelo.com/2009/05/30/my-top-10-ubuntu-aliases/#comments</comments>
		<pubDate>Sat, 30 May 2009 09:25:50 +0000</pubDate>
		<dc:creator>brockangelo</dc:creator>
				<category><![CDATA[Bash]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[alias]]></category>
		<category><![CDATA[aliases]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[command prompt]]></category>
		<category><![CDATA[command shell]]></category>
		<category><![CDATA[shell script]]></category>

		<guid isPermaLink="false">http://brockangelo.com/?p=773</guid>
		<description><![CDATA[10 Ubunutu Aliases You Can't Live Without


Related posts:<ol><li><a href='http://brockangelo.com/2008/10/13/create-aliases-in-ubuntu/' rel='bookmark' title='Permanent Link: Create Aliases in Ubuntu'>Create Aliases in Ubuntu</a></li><li><a href='http://brockangelo.com/2008/11/02/how-to-remove-non-empty-directories-in-linux/' rel='bookmark' title='Permanent Link: How to Remove Non-Empty Directories in Linux'>How to Remove Non-Empty Directories in Linux</a></li><li><a href='http://brockangelo.com/2008/09/05/mounting-ubuntu-server-to-a-novell-server/' rel='bookmark' title='Permanent Link: Mounting Ubuntu Server to a Novell Server'>Mounting Ubuntu Server to a Novell Server</a></li></ol>]]></description>
			<content:encoded><![CDATA[<h2>aka: The Ultimate List of Ubuntu Aliases</h2>
<p>Okay, maybe this isn&#8217;t the <em>ultimate</em> list, and maybe it&#8217;s more than 10, but this is my list of essential, must-have aliases for <a href="http://www.ubuntu.com/">Ubuntu</a> (or any version of Linux). Aliases are &#8220;shortcuts&#8221;. For example, if you&#8217;re at the command prompt and want to exit,  you normally type <code>exit</code>. But I have an alias for the letter <code>e</code> to exit. I cut my typing by 75%!! Do this all throughout your workflow and you&#8217;ll seriously wonder how you ever lived without it. Backup your aliases. </p>
<p>By adding these aliases, I have turned 277 characters of typing down to just 35. That&#8217;s a reduction of over 87%!!! Finally, I can leave work at 10am.  <img src='http://brockangelo.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />   </p>
<p>If you want to use an alias in <a href="http://www.ubuntu.com/">Ubuntu Linux</a>, insert these commands (or any other commands that speed up your workflow) at the bottom of your <code>.profile</code> or <code>.bashrc</code> files:</p>
<blockquote><ul>
alias sp=&#8217;sudo pico&#8217;<br />
alias la=&#8217;ls -alh&#8217;<br />
alias m=&#8217;mutt&#8217;<br />
alias e=&#8217;exit&#8217;<br />
alias cdw=&#8217;cd /var/www/&#8217;</p>
<ul>alias cdb=&#8217;cd /var/www/brockangelo/&#8217;<br />
alias cda=&#8217;cd /var/www/angeloarchive/&#8217; <em style="color:blue">(if you host multiple websites, replace the &#8220;a&#8221; with a website identifier. aka, photoshopsamurai = ps)</em><br />
alias cdps=&#8217;cd /var/www/photoshopsamurai/&#8217;</ul>
<p>alias cdn=&#8217;cd /usr/local/nagios/etc/&#8217;<br />
alias nr=&#8217;sudo /etc/init.d/nagios restart&#8217;<br />
alias ar=&#8217;sudo /etc/init.d/apache2 restart&#8217;<br />
alias coffee=&#8217;cat > /var/www/brockangelo/coffees.txt&#8217; <em style="color:blue">(I used to have a coffee-counter on my website and I would update the number of coffees my espresso machine had made &#8211; you can use this to <strong>replace</strong> the contents of a text file quickly)</em><br />
alias s=&#8217;sudo&#8217;<br />
alias aa=&#8217;/home/brock/scripts/add_alias.sh&#8217; <em style="color:blue">(I created a shell script to add new aliases by just typing aa &#8211; leave a comment if you&#8217;d like to download the script)</em>
</ul>
</blockquote>


<p>Related posts:<ol><li><a href='http://brockangelo.com/2008/10/13/create-aliases-in-ubuntu/' rel='bookmark' title='Permanent Link: Create Aliases in Ubuntu'>Create Aliases in Ubuntu</a></li><li><a href='http://brockangelo.com/2008/11/02/how-to-remove-non-empty-directories-in-linux/' rel='bookmark' title='Permanent Link: How to Remove Non-Empty Directories in Linux'>How to Remove Non-Empty Directories in Linux</a></li><li><a href='http://brockangelo.com/2008/09/05/mounting-ubuntu-server-to-a-novell-server/' rel='bookmark' title='Permanent Link: Mounting Ubuntu Server to a Novell Server'>Mounting Ubuntu Server to a Novell Server</a></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://brockangelo.com/2009/05/30/my-top-10-ubuntu-aliases/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Delete Comment Spam using a Cron Job</title>
		<link>http://brockangelo.com/2009/05/23/delete-comment-spam-using-a-cron-job/</link>
		<comments>http://brockangelo.com/2009/05/23/delete-comment-spam-using-a-cron-job/#comments</comments>
		<pubDate>Sat, 23 May 2009 17:46:12 +0000</pubDate>
		<dc:creator>brockangelo</dc:creator>
				<category><![CDATA[Bash]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[akismet]]></category>
		<category><![CDATA[cron]]></category>
		<category><![CDATA[delete-spam-daily]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[spam]]></category>

		<guid isPermaLink="false">http://brockangelo.com/?p=751</guid>
		<description><![CDATA[Delete all the comments marked as spam automatically using cron.


Related posts:<ol><li><a href='http://brockangelo.com/2009/05/30/my-top-10-ubuntu-aliases/' rel='bookmark' title='Permanent Link: My Top 10 Ubuntu Aliases'>My Top 10 Ubuntu Aliases</a></li><li><a href='http://brockangelo.com/2008/10/13/create-aliases-in-ubuntu/' rel='bookmark' title='Permanent Link: Create Aliases in Ubuntu'>Create Aliases in Ubuntu</a></li><li><a href='http://brockangelo.com/2009/05/12/how-to-add-uploaded-media-to-wp-downloadmanager/' rel='bookmark' title='Permanent Link: How to Add Uploaded Media to WP-DownloadManager'>How to Add Uploaded Media to WP-DownloadManager</a></li></ol>]]></description>
			<content:encoded><![CDATA[<p><strong>Delete Comment Spam using a Cron Job</strong></p>
<p>WordPress catches all of the comment spam, but it doesn&#8217;t seem to delete it often enough. If you have a high traffic site, this can become megabytes in your database. Bleh. I don&#8217;t have a high traffic site, but I sync my databases off-site everyday and spam wastes my bandwidth. So I delete all the comments marked as spam automatically each day using a scheduled cron job so that I never even have to see it. Could I possibly delete a real comment? Yes. Does the convenience of never even knowing about comment spam outweigh the risk? You bet.</p>
<p>Create a bash script in your scripts folder by typing this at the command prompt:</p>
<blockquote><p><code>sudo pico /home/brockangelo/scripts/del_spam.sh</code></p></blockquote>
<blockquote><p><strong>sudo:</strong>  elevate privileges<br />
<strong>pico:</strong>   use your editor of choice<br />
<strong>/home&#8230;/scripts/:</strong>   wherever you keep all your bash scripts<br />
<strong>del_spam.sh:  </strong>name it something obvious</p></blockquote>
<p>By the way, bash scripts are as easily made as windows batch files. You just put in the code and put a .sh at the end. Inside &#8220;del_spam.sh&#8221; add the following:</p>
<blockquote><p><code>mysql -u username -ppassword -e "delete from wp_comments where comment_approved='spam';" brockangelo</code></p></blockquote>
<p>Where &#8220;brockangelo&#8221; is the name of the database. Repeat this line for each WordPress site you host. Then you need to set this up as a cron job and schedule it for once a night. Or, you can download my plugin that deletes spam daily. <a href="http://brockangelo.com/wordpress/plugins/delete-spam-daily/">Delete Spam Daily</a> plugin.</p>
<p>By the way, the username and password format in that command you see above looks wrong, but it is typed correctly. You put &#8220;-u (space) username&#8221; then you squish the &#8220;-p&#8221; and &#8220;password&#8221; together like this &#8220;-u username -ppassword&#8221;.</p>


<p>Related posts:<ol><li><a href='http://brockangelo.com/2009/05/30/my-top-10-ubuntu-aliases/' rel='bookmark' title='Permanent Link: My Top 10 Ubuntu Aliases'>My Top 10 Ubuntu Aliases</a></li><li><a href='http://brockangelo.com/2008/10/13/create-aliases-in-ubuntu/' rel='bookmark' title='Permanent Link: Create Aliases in Ubuntu'>Create Aliases in Ubuntu</a></li><li><a href='http://brockangelo.com/2009/05/12/how-to-add-uploaded-media-to-wp-downloadmanager/' rel='bookmark' title='Permanent Link: How to Add Uploaded Media to WP-DownloadManager'>How to Add Uploaded Media to WP-DownloadManager</a></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://brockangelo.com/2009/05/23/delete-comment-spam-using-a-cron-job/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Create Aliases in Ubuntu</title>
		<link>http://brockangelo.com/2008/10/13/create-aliases-in-ubuntu/</link>
		<comments>http://brockangelo.com/2008/10/13/create-aliases-in-ubuntu/#comments</comments>
		<pubDate>Mon, 13 Oct 2008 18:35:55 +0000</pubDate>
		<dc:creator>brockangelo</dc:creator>
				<category><![CDATA[Bash]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[alias]]></category>
		<category><![CDATA[aliases]]></category>
		<category><![CDATA[command shell]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[shortcuts]]></category>
		<category><![CDATA[top 10]]></category>

		<guid isPermaLink="false">http://brockangelo.com/?p=372</guid>
		<description><![CDATA[How to Create an Alias in Ubuntu
If you run the same commands in Linux (or Ubuntu) all the time, you can add what is called an &#8220;alias&#8221; to your user account. For example, I regularly type:
ls -alh
So I setup an alias so that I can just type la. (also, see my Top 10 Aliases list) [...]


Related posts:<ol><li><a href='http://brockangelo.com/2009/05/30/my-top-10-ubuntu-aliases/' rel='bookmark' title='Permanent Link: My Top 10 Ubuntu Aliases'>My Top 10 Ubuntu Aliases</a></li><li><a href='http://brockangelo.com/2009/05/23/delete-comment-spam-using-a-cron-job/' rel='bookmark' title='Permanent Link: Delete Comment Spam using a Cron Job'>Delete Comment Spam using a Cron Job</a></li><li><a href='http://brockangelo.com/2008/11/02/how-to-remove-non-empty-directories-in-linux/' rel='bookmark' title='Permanent Link: How to Remove Non-Empty Directories in Linux'>How to Remove Non-Empty Directories in Linux</a></li></ol>]]></description>
			<content:encoded><![CDATA[<p><strong>How to Create an Alias in Ubuntu</strong></p>
<p>If you run the same commands in Linux (or Ubuntu) all the time, you can add what is called an &#8220;alias&#8221; to your user account. For example, I regularly type:</p>
<blockquote><p><code>ls -alh</code></p></blockquote>
<p>So I setup an alias so that I can just type <strong>la</strong>. (also, see my <a href="http://brockangelo.com/2009/05/30/my-top-10-ubuntu-aliases/">Top 10 Aliases</a> list) To do this, simply edit your &#8220;profile&#8221;. Bash is the program that you typically use when you are in a command shell, so it may be called your &#8220;bash profile&#8221;. Your profile is in your Home folder and stores all of your preferences. Just edit the &#8220;.profile&#8221; or the &#8220;.bash_profile&#8221; if it exists.</p>
<blockquote><p><code>cd ~<br />
pico edit .profile<br />
</code></p></blockquote>
<p>Add the following code to the bottom:</p>
<blockquote><p><code>alias la='ls -alh'<br />
</code></p></blockquote>
<p>Now when you are typing at the command prompt, you just type <strong>la</strong> and it acts like you typed <strong>ls -alh</strong>. Pretty handy.</p>


<p>Related posts:<ol><li><a href='http://brockangelo.com/2009/05/30/my-top-10-ubuntu-aliases/' rel='bookmark' title='Permanent Link: My Top 10 Ubuntu Aliases'>My Top 10 Ubuntu Aliases</a></li><li><a href='http://brockangelo.com/2009/05/23/delete-comment-spam-using-a-cron-job/' rel='bookmark' title='Permanent Link: Delete Comment Spam using a Cron Job'>Delete Comment Spam using a Cron Job</a></li><li><a href='http://brockangelo.com/2008/11/02/how-to-remove-non-empty-directories-in-linux/' rel='bookmark' title='Permanent Link: How to Remove Non-Empty Directories in Linux'>How to Remove Non-Empty Directories in Linux</a></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://brockangelo.com/2008/10/13/create-aliases-in-ubuntu/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
