

<?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>ShareDigest blog &#187; linux</title>
	<atom:link href="http://blog.sharedigest.com/category/linux/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.sharedigest.com</link>
	<description>Trading, software, web and random stuff</description>
	<lastBuildDate>Tue, 06 Jul 2010 11:30:16 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Cron Task For Automated Backups</title>
		<link>http://blog.sharedigest.com/cron-task-for-automated-backups/</link>
		<comments>http://blog.sharedigest.com/cron-task-for-automated-backups/#comments</comments>
		<pubDate>Sun, 18 Oct 2009 20:56:46 +0000</pubDate>
		<dc:creator>SD</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[automated backup]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[cron]]></category>
		<category><![CDATA[cron job]]></category>
		<category><![CDATA[linux shell script]]></category>
		<category><![CDATA[scripts]]></category>
		<category><![CDATA[shell]]></category>

		<guid isPermaLink="false">http://blog.sharedigest.com/?p=111</guid>
		<description><![CDATA[


What we&#8217;re going to cover in this tutorial, is how to set up a cron job on a Centos 5  linux server. The basic problem I had, was that our server&#8217;s /backup/cpbackup/ folder was getting filled with (automated) backups very fast, taking up tonnes of disk space very quickly (only 7.5GB total available on [...]]]></description>
			<content:encoded><![CDATA[<table>
<tr>
<td width="50%">
What we&#8217;re going to cover in this tutorial, is how to set up a cron job on a Centos 5  linux server. The basic problem I had, was that our server&#8217;s /backup/cpbackup/ folder was getting filled with (automated) backups very fast, taking up tonnes of disk space very quickly (only 7.5GB total available on this VPS! &#8211; perhaps time to look for a better one?). We&#8217;ll learn how to use cron jobs here to achieve the following:</p>
</td>
<td width="50%">
<div align="right">
<script type="text/javascript"><!--
google_ad_client = "pub-1739519678603459";
/* SDblog_300_250, created 9/24/09 */
google_ad_slot = "6287581496";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>
</td>
</tr>
</table>
<ul>
<li>Execute a script at a specified time once a week, which peforms the following:</li>
<li>Create a zipped-tar backup of the folder /backup/cpbackup/ at /backup/cpbackup_ddmmyy.tar.gz</li>
<li>Clear the entire /backup/cpbackup/ folder of all contents, freeing up this space</li>
<li>Email the administrator that the new backup_x.tar.gz file has been created</li>
<li>(Optionally): Automatically copy this file over to another (larger capacity) server</li>
</ul>
<p><strong>Step 1: Install A Cron Task</strong></p>
<p>A great little tutorial showing exactly how easy it is to install a cron task on any linux system, can be found <a href="http://www.cyberciti.biz/faq/how-do-i-add-jobs-to-cron-under-linux-or-unix-oses/" target="_blank">here</a>.</p>
<p><strong>Step 2: Create the Shell Script</strong></p>
<p>The script which performs the magic, looks like this:</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">#!/bin/sh
# Create a zipped-tar backup of the folder /backup/cpbackup/ at /backup/cpbackup_ddmmyy.tar.gz
# Clear the entire /backup/cpbackup/ folder of all contents, freeing up this space
# Email the administrator that the new backup_x.tar.gz file has been created
# (Optionally): Automatically copy this file over to another (larger capacity) server
&nbsp;
EMAIL=&quot;youremail@gmail.com&quot;
NOW=$(date +&quot;%d-%b-%y_%H%M&quot;)
BFILE=&quot;/backup/wz_cbackup_$NOW.tar.gz&quot;
MSG=&quot;&quot;
SUBJECT=&quot;&quot;
&nbsp;
#create tar zip file:
tar -czf $BFILE /backup/cpbackup/
&nbsp;
if [ &quot;$?&quot; -ne &quot;0&quot; ]; then
	MSG=&quot;tar -czf $BFILE /backup/cpbackup/ failed.&quot;
	SUBJECT=&quot;weeklyZip: $BFILE creation failed!&quot;
else
  	MSG=&quot;$BFILE successfully created. Please either download or copy to new server.&quot;
  	SUBJECT=&quot;weeklyZip: $BFILE  successfully created.&quot;
&nbsp;
	#Success, so we clear out the /backup/cpbackup/ folder:
	rm -R /backup/cpbackup/* -f
fi
&nbsp;
/bin/mail -s &quot;$SUBJECT&quot; &quot;$EMAIL&quot; &amp;lt;&amp;lt;&amp;lt; &quot;$MSG&quot;</pre></div></div>

<div align="center"><script type="text/javascript"><!--
google_ad_client = "pub-1739519678603459";
/* SDblog_300_250, created 9/24/09 */
google_ad_slot = "6287581496";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>
<div id="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://blog.sharedigest.com/subversion-using-apache-and-ssl/" rel="bookmark">Subversion Using Apache And SSL</a></li><li><a href="http://blog.sharedigest.com/handy-linux-commands/" rel="bookmark">Handy Linux Commands</a></li><li><a href="http://blog.sharedigest.com/handy-subversion-commands/" rel="bookmark">Handy Subversion Commands</a></li><li><a href="http://blog.sharedigest.com/linux-shell-scripting-check-if-folder-exists/" rel="bookmark">Linux Shell Scripting: Check if Folder Exists</a></li><li><a href="http://blog.sharedigest.com/algo-trading-101-part-1-getting-started/" rel="bookmark">Algo-Trading 101 Part 1: Getting Started</a></li></ul></div><hr /><h2>Related posts:</h2><ul><li><a href="http://blog.sharedigest.com/algo-trading-101-part-1-getting-started/" rel="bookmark" title="Permanent Link: Algo-Trading 101 Part 1: Getting Started">Algo-Trading 101 Part 1: Getting Started</a></li><li><a href="http://blog.sharedigest.com/the-stock-market-basics/" rel="bookmark" title="Permanent Link: The Stock Market: Basics">The Stock Market: Basics</a></li><li><a href="http://blog.sharedigest.com/australian-market-news-thursday-march-18/" rel="bookmark" title="Permanent Link: Thursday, March 18">Thursday, March 18</a></li><li><a href="http://blog.sharedigest.com/australian-market-news-thursday-march-18/" rel="bookmark" title="Permanent Link: Thursday, March 18">Thursday, March 18</a></li><li><a href="http://blog.sharedigest.com/australian-market-news-thursday-march-18/" rel="bookmark" title="Permanent Link: Thursday, March 18">Thursday, March 18</a></li></ul><hr /><small>Copyright &copy; 2008<br /> This feed is for personal, non-commercial use only. <br /> The use of this feed on other websites breaches copyright. If this content is not in your news reader, it makes the page you are viewing an infringement of the copyright. (Digital Fingerprint:<br /> )</small>]]></content:encoded>
			<wfw:commentRss>http://blog.sharedigest.com/cron-task-for-automated-backups/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Handy Subversion Commands</title>
		<link>http://blog.sharedigest.com/handy-subversion-commands/</link>
		<comments>http://blog.sharedigest.com/handy-subversion-commands/#comments</comments>
		<pubDate>Wed, 14 Oct 2009 05:53:46 +0000</pubDate>
		<dc:creator>SD</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[handy subversion commands]]></category>
		<category><![CDATA[ssl]]></category>
		<category><![CDATA[subversion]]></category>
		<category><![CDATA[svn commands]]></category>
		<category><![CDATA[useful subversion]]></category>

		<guid isPermaLink="false">http://blog.sharedigest.com/?p=102</guid>
		<description><![CDATA[Create And Import Into a New Subversion (SVN) Repository:
Replace &#8216;$repos_name&#8217; with the name of your SVN repository &#8211; typically the name of the project folder.
(Note: For further repository admin functions and general SVN admin, see here).

$ svnadmin create /var/svn/$repos_name
&#160;
#Note: To remove a repository, simply delete the directory directly as root user: (don't do this now [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Create And Import Into a New Subversion (SVN) Repository:</strong><br />
Replace &#8216;$repos_name&#8217; with the name of your SVN repository &#8211; typically the name of the project folder.<br />
(Note: For further repository admin functions and general SVN admin, see <a href="http://svnbook.red-bean.com/en/1.5/svn-book.html#svn.reposadmin" target="_blank">here</a>).</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">$ svnadmin create /var/svn/$repos_name
&nbsp;
#Note: To remove a repository, simply delete the directory directly as root user: (don't do this now unless you want to remove it :-):
sudo rm -R /var/svn/$repos_name</pre></div></div>

<div align="center"><!--adsense#SDblog_300_250--></div>
<p>The recommended organization for a repository is to use the folders trunk, branches and tags, which we create using:</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">$ svn mkdir file:///var/svn/$repos_name/trunk
$ svn mkdir file:///var/svn/$repos_name/branches
$ svn mkdir file:///var/svn/$repos_name/tags</pre></div></div>

<p>Now let&#8217;s import our project folder to this repository&#8217;s &#8216;trunk&#8217; (main development line) folder): We do this the FIRST TIME we want to start tracking a project in the repository.</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">$ svn import localProjFolder file:///var/svn/$repos_name/trunk</pre></div></div>

<p><strong>Checking Out a Folder From a Repository:</strong></p>
<p>Before having a local &#8216;working copy&#8217; we need to check out the project folder for the first time:</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">$ svn checkout file:///var/svn/$repos_name/trunk {optional: localProjFolder}</pre></div></div>

<p>Now we have a local working copy our project. We can make whatever changes we like, as in a usual file system structure. Note that any changes, APART FROM A STRAIGHT MODIFICATION TO A FILE (using a text editor for example), needs to be preceded by an &#8217;svn&#8217; to the command. For example, &#8217;svn mkdir&#8217; needs to be run to add a directory to the project. This is because SVN needs to be made aware of these changes.</p>
<p><strong>Editing A File</strong></p>
<p>Let&#8217;s say I have edited the file SecNew. java. We can now check the status of scheduled changes to our folder by running:</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">$ svn status
M      SecNew.java</pre></div></div>

<p>In the above, we can see that the file SecNew.java was modified (in the working copy), and is due for modification in the repository.</p>
<p><strong>Add A Folder To Our SVN Project</strong></p>
<p>Let&#8217;s now add a folder to our project. I am going to add &#8216;custom&#8217; to the folder SDCommon/src/org/:</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">$ svn mkdir ~/workspace/SDCommon/src/org/custom
A      custom</pre></div></div>

<p>Note how I used &#8217;svn&#8217; before the usual &#8216;mkdir&#8217; command. Remember, only pure editing of files does NOT require this preceding &#8217;svn&#8217; to be used.<br />
The last line shows us that the folder was successfully created and is scheduled to be (A)dded to the repositoy.</p>
<p><strong>Seeing What Changes We&#8217;ve Made To Our Folder: svn status &amp; svn diff</strong></p>
<p>Simply run the &#8217;svn status&#8217; command:</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">$ svn status
M      SecNew.java
A      custom</pre></div></div>

<p>We can see the changes that are scheduled to be made to the repository on a commit.</p>
<p>Let&#8217;s now check out what specific changes have occurred to files that have been modified (SecNew.java in this case):</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">pacific@mainbox:~/workspace/SDCommon/src/org$ svn diff
&nbsp;
Index: SecNew.java
===================================================================
--- SecNew.java (revision 6)
+++ SecNew.java (working copy)
@@ -5,6 +5,8 @@
 import org.apache.log4j.Logger;
&nbsp;
 public class Security { //can be overridden if need be
+       protected DateTime StartDate = null;
+
        protected String ticker = null;
        protected String exchcode = null; //yahoo ec
        protected String name = null;</pre></div></div>

<p>Lines that have a &#8216;+&#8217; next to them, have been added. (a &#8216;-&#8217; indicates lines that have been removed).</p>
<div align="center"><!--adsense#SDblog_300_250--></div>
<div id="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://blog.sharedigest.com/handy-linux-commands/" rel="bookmark">Handy Linux Commands</a></li><li><a href="http://blog.sharedigest.com/subversion-using-apache-and-ssl/" rel="bookmark">Subversion Using Apache And SSL</a></li><li><a href="http://blog.sharedigest.com/linux-shell-scripting-check-if-folder-exists/" rel="bookmark">Linux Shell Scripting: Check if Folder Exists</a></li><li><a href="http://blog.sharedigest.com/cron-task-for-automated-backups/" rel="bookmark">Cron Task For Automated Backups</a></li><li><a href="http://blog.sharedigest.com/optimizing-mysql-1-using-indexes/" rel="bookmark">Optimizing MySQL 1: Using Indexes</a></li></ul></div><hr /><h2>Related posts:</h2><ul><li><a href="http://blog.sharedigest.com/handy-linux-commands/" rel="bookmark" title="Permanent Link: Handy Linux Commands">Handy Linux Commands</a></li><li><a href="http://blog.sharedigest.com/subversion-using-apache-and-ssl/" rel="bookmark" title="Permanent Link: Subversion Using Apache And SSL">Subversion Using Apache And SSL</a></li></ul><hr /><small>Copyright &copy; 2008<br /> This feed is for personal, non-commercial use only. <br /> The use of this feed on other websites breaches copyright. If this content is not in your news reader, it makes the page you are viewing an infringement of the copyright. (Digital Fingerprint:<br /> )</small>]]></content:encoded>
			<wfw:commentRss>http://blog.sharedigest.com/handy-subversion-commands/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Subversion Using Apache And SSL</title>
		<link>http://blog.sharedigest.com/subversion-using-apache-and-ssl/</link>
		<comments>http://blog.sharedigest.com/subversion-using-apache-and-ssl/#comments</comments>
		<pubDate>Tue, 13 Oct 2009 07:41:21 +0000</pubDate>
		<dc:creator>SD</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[ssl]]></category>
		<category><![CDATA[subversion]]></category>

		<guid isPermaLink="false">http://blog.sharedigest.com/?p=90</guid>
		<description><![CDATA[So you&#8217;d like to host a SVN repository which allows fine-grained access control and different users and projects? Look no further, as we&#8217;ll be covering how to achieve just that in this post. What we&#8217;ll be using is the Apache Web server (with SSL encryption), SubVersion and Trac which is a web-based software management package. [...]]]></description>
			<content:encoded><![CDATA[<p>So you&#8217;d like to host a SVN repository which allows fine-grained access control and different users and projects? Look no further, as we&#8217;ll be covering how to achieve just that in this post. What we&#8217;ll be using is the Apache Web server (with SSL encryption), SubVersion and Trac which is a web-based software management package.  I&#8217;ll be doing this on my Kubuntu Hardy Heron (Linux debian) machine, so if you&#8217;re installing it under a different version / OS instructions may vary slightly.</p>
<p><em>Note: You will need sudo access rights and a basic text editor (such as Kate) to do these.</em></p>
<div align="center"><!--adsense#SDblog_300_250--></div>
<p><strong>Step 1: Install Apache httpd</strong></p>
<p>This is as simple as installing the &#8216;apache2&#8242; package using apt-get or aptitude:</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">$ sudo aptitude install apache2</pre></div></div>

<p>For further detail on the installation of the Apache web server, see <a href="https://help.ubuntu.com/6.06/ubuntu/serverguide/C/httpd.html" target="_blank">this</a>.</p>
<p><strong>Step 2: Install Subversion &amp; Apache SVN Libraries</strong><br />
Similar to step 1, to install the subversion and the svn libraries for apache, simply run:</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">$ sudo aptitude install subversion libapache2-svn</pre></div></div>

<p><strong>Step 3: Enable SSL</strong><br />
First we enable the Apache ssl module, followed by adding &#8216;Listen 443&#8242; to the Apache2 port configuration file (see below):</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">$ sudo a2enmod ssl
$ sudo kate /etc/apache2/ports.conf</pre></div></div>

<p>After opening the ports.conf file, make sure that the following is in the file:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;IfModule mod_ssl.c&gt;
        Listen 443
&lt;/IfModule&gt;</pre></div></div>

<p><strong>Step 4: Generate SSL Certificate</strong><br />
Once we have enabled the SSL module, we need to generate a certificate to use:</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">#create dir where ssl certificates will go:
$ sudo mkdir /etc/apache2/ssl  
&nbsp;
#create certificate (should launch application asking some basic questions)
$ sudo /usr/sbin/make-ssl-cert /usr/share/ssl-cert/ssleay.cnf /etc/apache2/ssl/apache.pem</pre></div></div>

<p><strong>Step 5: Create a Virtual Host </strong></p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">#copy default folder to svnserver folder
$ sudo cp /etc/apache2/sites-available/default /etc/apache2/sites-available/svnserver
&nbsp;
#Open svnserver:
$ sudo kate /etc/apache2/sites-available/svnserver</pre></div></div>

<p>Now, within the svnserver file, change the following:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&quot;NameVirtualHost *&quot; to &quot;NameVirtualHost *:443&quot;
&quot;&lt;VirtualHost *&gt;&quot;  to  &lt;VirtualHost *:443&gt;&quot;</pre></div></div>

<p>Directly under &#8216;ServerAdmin&#8217;, add the following:</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">SSLEngine on
SSLCertificateFile /etc/apache2/ssl/apache.pem
SSLProtocol all
SSLCipherSuite HIGH:MEDIUM</pre></div></div>

<div align="center"><!--adsense#SDblog_300_250--></div>
<p><strong>Step 6: Enable The Site</strong></p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">$ sudo a2ensite svnserver
$ sudo /etc/init.d/apache2 restart
#To avoid warnings when restarting apache2, add &quot;ServerName $your_server_name&quot; to /etc/apache2/apache2.conf</pre></div></div>

<p><strong>Step 7: Add Repositories</strong><br />
To host more than one repository, use the following configurations, replacing $REPOS with the name of your repository-folder, for example I&#8217;ve used &#8217;svn-repos&#8217;</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">$ sudo mkdir /var/svn
$ sudo svnadmin create /var/svn/$REPOS
$ sudo chown -R www-data:www-data /var/svn/$REPOS
$ sudo chmod -R g+ws /var/svn/$REPOS</pre></div></div>

<p><strong>Step 8: Add Authenticated User</strong><br />
Add a user using the following, substituting $username with your selected username. You&#8217;ll be prompted for a password.</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">$ sudo htpasswd -c -m /etc/apache2/dav_svn.passwd $username</pre></div></div>

<p><strong>Step 9: WebDAV and SVN Configuration</strong><br />
Open the file: /etc/apache2/mods-available/dav_svn.conf using Kate, and either enable (uncomment) or add the following:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;Location /svn&gt;
DAV svn
SVNParentPath /var/svn/
AuthType Basic
AuthName &quot;Subversion Repository&quot;
AuthUserFile /etc/apache2/dav_svn.passwd
Require valid-user
SSLRequireSSL
&lt;/Location&gt;</pre></div></div>

<p>Now restart the Apache2 webserver one final time:</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">$ sudo /etc/init.d/apache2 restart</pre></div></div>

<p><strong>Step 10: Test It !</strong><br />
Point your browser to: https://localhost/svn/$REPOS   (where $REPOS is your specific svn repository)<br />
You should now see something like &#8220;Revision 0: /&#8221; appear &#8211; this is our first SVN repository contents. Obviously it is empty, so let&#8217;s get right stuck into<br />
testing it out with some SVN!</p>
<div align="center"><!--adsense#SDblog_300_250--></div>
<div id="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://blog.sharedigest.com/handy-subversion-commands/" rel="bookmark">Handy Subversion Commands</a></li><li><a href="http://blog.sharedigest.com/linux-shell-scripting-check-if-folder-exists/" rel="bookmark">Linux Shell Scripting: Check if Folder Exists</a></li><li><a href="http://blog.sharedigest.com/cron-task-for-automated-backups/" rel="bookmark">Cron Task For Automated Backups</a></li><li><a href="http://blog.sharedigest.com/handy-linux-commands/" rel="bookmark">Handy Linux Commands</a></li><li><a href="http://blog.sharedigest.com/australian-market-news-monday-march-8/" rel="bookmark">Monday, March 8</a></li></ul></div><hr /><h2>Related posts:</h2><ul><li><a href="http://blog.sharedigest.com/handy-subversion-commands/" rel="bookmark" title="Permanent Link: Handy Subversion Commands">Handy Subversion Commands</a></li></ul><hr /><small>Copyright &copy; 2008<br /> This feed is for personal, non-commercial use only. <br /> The use of this feed on other websites breaches copyright. If this content is not in your news reader, it makes the page you are viewing an infringement of the copyright. (Digital Fingerprint:<br /> )</small>]]></content:encoded>
			<wfw:commentRss>http://blog.sharedigest.com/subversion-using-apache-and-ssl/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Handy Linux Commands</title>
		<link>http://blog.sharedigest.com/handy-linux-commands/</link>
		<comments>http://blog.sharedigest.com/handy-linux-commands/#comments</comments>
		<pubDate>Mon, 05 Oct 2009 00:45:40 +0000</pubDate>
		<dc:creator>SD</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[bash commands]]></category>
		<category><![CDATA[handy linux commands]]></category>
		<category><![CDATA[linux commands]]></category>
		<category><![CDATA[linux shell]]></category>
		<category><![CDATA[scripting]]></category>

		<guid isPermaLink="false">http://blog.sharedigest.com/?p=81</guid>
		<description><![CDATA[Recursively Remove All Files With a Specific Extension:
Suppose you want to delete, recursively, all files with a specific file extension (e.g. a Java folder containing .class files). Run the following command:
$ find folderToStart/ -name \*.extension -exec rm {} \;
Bulk Renaming All Files Within a Folder

To replace a string within all files within a folder, just [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Recursively Remove All Files With a Specific Extension:</strong></p>
<p>Suppose you want to delete, recursively, all files with a specific file extension (e.g. a Java folder containing .class files). Run the following command:</p>
<pre>$ find folderToStart/ -name \*.extension -exec rm {} \;</pre>
<p><strong>Bulk Renaming All Files Within a Folder</strong></p>
<div align="center"><!--adsense#SDblog_300_250--></div>
<p>To replace a string within all files within a folder, just run the following:</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">$ for i in *; do newname=`echo $i|sed 's/search_txt/replace_txt/g'`; echo $newname; mv $i $newname; done</pre></div></div>

<p>For more handy applications to bulk renaming using regular expressions, see <a href="http://www.go2linux.org/rename-bulk-files-with-linux-console-command" target="_blank">this</a>.</p>
<p><strong>Check Folder Sizes on System<br />
</strong></p>
<p>Very handy tutorial on how to do all aspects of disk space usage, can be found <a href="http://www.linux.com/archive/articles/51600" target="_blank">here</a>.</p>
<div id="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://blog.sharedigest.com/handy-subversion-commands/" rel="bookmark">Handy Subversion Commands</a></li><li><a href="http://blog.sharedigest.com/linux-shell-scripting-check-if-folder-exists/" rel="bookmark">Linux Shell Scripting: Check if Folder Exists</a></li><li><a href="http://blog.sharedigest.com/cron-task-for-automated-backups/" rel="bookmark">Cron Task For Automated Backups</a></li><li><a href="http://blog.sharedigest.com/subversion-using-apache-and-ssl/" rel="bookmark">Subversion Using Apache And SSL</a></li><li><a href="http://blog.sharedigest.com/australian-market-news-monday-march-22/" rel="bookmark">Australian Market - Monday, March 22</a></li></ul></div><hr /><h2>Related posts:</h2><ul><li><a href="http://blog.sharedigest.com/handy-subversion-commands/" rel="bookmark" title="Permanent Link: Handy Subversion Commands">Handy Subversion Commands</a></li><li><a href="http://blog.sharedigest.com/linux-shell-scripting-check-if-folder-exists/" rel="bookmark" title="Permanent Link: Linux Shell Scripting: Check if Folder Exists">Linux Shell Scripting: Check if Folder Exists</a></li><li><a href="http://blog.sharedigest.com/cron-task-for-automated-backups/" rel="bookmark" title="Permanent Link: Cron Task For Automated Backups">Cron Task For Automated Backups</a></li><li><a href="http://blog.sharedigest.com/algo-trading-101-part-1-getting-started/" rel="bookmark" title="Permanent Link: Algo-Trading 101 Part 1: Getting Started">Algo-Trading 101 Part 1: Getting Started</a></li><li><a href="http://blog.sharedigest.com/subversion-using-apache-and-ssl/" rel="bookmark" title="Permanent Link: Subversion Using Apache And SSL">Subversion Using Apache And SSL</a></li></ul><hr /><small>Copyright &copy; 2008<br /> This feed is for personal, non-commercial use only. <br /> The use of this feed on other websites breaches copyright. If this content is not in your news reader, it makes the page you are viewing an infringement of the copyright. (Digital Fingerprint:<br /> )</small>]]></content:encoded>
			<wfw:commentRss>http://blog.sharedigest.com/handy-linux-commands/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Linux Shell Scripting: Check if Folder Exists</title>
		<link>http://blog.sharedigest.com/linux-shell-scripting-check-if-folder-exists/</link>
		<comments>http://blog.sharedigest.com/linux-shell-scripting-check-if-folder-exists/#comments</comments>
		<pubDate>Fri, 02 Oct 2009 06:54:55 +0000</pubDate>
		<dc:creator>SD</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[check if folder exists]]></category>
		<category><![CDATA[folder exists]]></category>
		<category><![CDATA[linux shell script]]></category>

		<guid isPermaLink="false">http://blog.sharedigest.com/?p=77</guid>
		<description><![CDATA[If we want to check if a folder exists we simply create the following .sh file:

#!/bin/bash
&#160;
if [ ! -d &#34;myFolder&#34; ]; then
	echo &#34;Creating myFolder&#34;
	sudo mkdir myFolder
fi
&#160;
if [ ! -d &#34;myFolder/subFolder&#34; ]; then
	echo &#34;Creating myFolder/subFolder&#34;
	sudo mkdir myFolder/subFolder
fi


Now you can run that using sudo and for example create a new folder where one didn&#8217;t exist before, if [...]]]></description>
			<content:encoded><![CDATA[<p>If we want to check if a folder exists we simply create the following .sh file:</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">#!/bin/bash
&nbsp;
if [ ! -d &quot;myFolder&quot; ]; then
	echo &quot;Creating myFolder&quot;
	sudo mkdir myFolder
fi
&nbsp;
if [ ! -d &quot;myFolder/subFolder&quot; ]; then
	echo &quot;Creating myFolder/subFolder&quot;
	sudo mkdir myFolder/subFolder
fi</pre></div></div>

<div align="center"><!--adsense#SDblog_300_250--></div>
<p>Now you can run that using sudo and for example create a new folder where one didn&#8217;t exist before, if its required by some other script, for example one mounting a windows XP drive over a network to the current Linux filesystem using Samba. See the post covering that for more details.</p>
<div id="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://blog.sharedigest.com/handy-subversion-commands/" rel="bookmark">Handy Subversion Commands</a></li><li><a href="http://blog.sharedigest.com/subversion-using-apache-and-ssl/" rel="bookmark">Subversion Using Apache And SSL</a></li><li><a href="http://blog.sharedigest.com/handy-linux-commands/" rel="bookmark">Handy Linux Commands</a></li><li><a href="http://blog.sharedigest.com/cron-task-for-automated-backups/" rel="bookmark">Cron Task For Automated Backups</a></li><li><a href="http://blog.sharedigest.com/optimizing-mysql-1-using-indexes/" rel="bookmark">Optimizing MySQL 1: Using Indexes</a></li></ul></div><hr /><h2>Related posts:</h2><ul><li><a href="http://blog.sharedigest.com/handy-subversion-commands/" rel="bookmark" title="Permanent Link: Handy Subversion Commands">Handy Subversion Commands</a></li><li><a href="http://blog.sharedigest.com/handy-linux-commands/" rel="bookmark" title="Permanent Link: Handy Linux Commands">Handy Linux Commands</a></li><li><a href="http://blog.sharedigest.com/cron-task-for-automated-backups/" rel="bookmark" title="Permanent Link: Cron Task For Automated Backups">Cron Task For Automated Backups</a></li><li><a href="http://blog.sharedigest.com/subversion-using-apache-and-ssl/" rel="bookmark" title="Permanent Link: Subversion Using Apache And SSL">Subversion Using Apache And SSL</a></li><li><a href="http://blog.sharedigest.com/optimizing-mysql-1-using-indexes/" rel="bookmark" title="Permanent Link: Optimizing MySQL 1: Using Indexes">Optimizing MySQL 1: Using Indexes</a></li></ul><hr /><small>Copyright &copy; 2008<br /> This feed is for personal, non-commercial use only. <br /> The use of this feed on other websites breaches copyright. If this content is not in your news reader, it makes the page you are viewing an infringement of the copyright. (Digital Fingerprint:<br /> )</small>]]></content:encoded>
			<wfw:commentRss>http://blog.sharedigest.com/linux-shell-scripting-check-if-folder-exists/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

