<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="http://feeds.feedburner.com/~d/styles/rss2full.xsl" type="text/xsl" media="screen"?><?xml-stylesheet href="http://feeds.feedburner.com/~d/styles/itemcontent.css" type="text/css" media="screen"?><rss 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:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>UNIX Tutorial: Learn UNIX</title>
	
	<link>http://www.unixtutorial.org</link>
	<description>Learn UNIX</description>
	<pubDate>Thu, 20 Nov 2008 15:56:54 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.2</generator>
	<language>en</language>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/UnixTutorial" type="application/rss+xml" /><item>
		<title>Confirm the Day of the Week Based on a Timestamp</title>
		<link>http://feeds.feedburner.com/~r/UnixTutorial/~3/459693357/</link>
		<comments>http://www.unixtutorial.org/2008/11/find-day-of-the-week-based-on-a-timestamp/#comments</comments>
		<pubDate>Thu, 20 Nov 2008 15:51:48 +0000</pubDate>
		<dc:creator>Gleb Reys</dc:creator>
		
		<category><![CDATA[Questions &amp; Answers]]></category>

		<category><![CDATA[date]]></category>

		<category><![CDATA[timestamp]]></category>

		<guid isPermaLink="false">http://www.unixtutorial.org/?p=155</guid>
		<description><![CDATA[I recently created a Unix Questions and Answers page, if you have a Unix question - feel free to ask it there using the submit form and I'll do my best to help you out.
Today's Unix question is this:
How can we write a shell script in unix to find the day of the week when [...]]]></description>
			<content:encoded><![CDATA[<p>I recently created a Unix Questions and Answers page, if you have a Unix question - feel free to ask it there using the submit form and I'll do my best to help you out.</p>
<p>Today's Unix question is this:</p>
<h4>How can we write a shell script in unix to find the day of the week when date is given?</h4>
<p>The solution for this is even simpler: there's no need for Unix scripting, all you need is to have <a href="http://en.wikipedia.org/wiki/Date_(Unix)">GNU date</a> command at your disposal. I've already shown you all the <a title="date and time calculations in unix" href="http://www.unixtutorial.org/2008/09/easy-date-calculations-in-unix-scripts-with-gnu-date/">basic date/time calculations</a> using this great tool, and that's just another way of using it.</p>
<h3>How to find a Day of the week based on timestamp</h3>
<p>All you need is to know the base date. Let's say I'm interested in October 16th, 2009. Here's how easy it is to confirm that day will be Friday:</p>
<pre>ubuntu$ <strong>date -d "Oct 16 2009" "+%a"</strong>
Fri</pre>
<p>That's it - enjoy!</p>
<h3>See also:</h3>
<ul>
<li><strong><a title="time and date" href="http://www.unixtutorial.org/2008/06/unix-scripting-time-and-date/">time and date in Unix</a></strong></li>
<li><strong><a title="date manipulations in Unix" href="http://www.unixtutorial.org/2008/09/easy-date-calculations-in-unix-scripts-with-gnu-date/">date calculations with GNU date command</a><br />
</strong></li>
</ul>
<img src="http://feeds.feedburner.com/~r/UnixTutorial/~4/459693357" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.unixtutorial.org/2008/11/find-day-of-the-week-based-on-a-timestamp/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.unixtutorial.org/2008/11/find-day-of-the-week-based-on-a-timestamp/</feedburner:origLink></item>
		<item>
		<title>How To Update atime and mtime for a File in Unix</title>
		<link>http://feeds.feedburner.com/~r/UnixTutorial/~3/455938341/</link>
		<comments>http://www.unixtutorial.org/2008/11/how-to-update-atime-and-mtime-for-a-file-in-unix/#comments</comments>
		<pubDate>Mon, 17 Nov 2008 12:41:14 +0000</pubDate>
		<dc:creator>Gleb Reys</dc:creator>
		
		<category><![CDATA[Basic stuff]]></category>

		<category><![CDATA[atime]]></category>

		<category><![CDATA[mtime]]></category>

		<category><![CDATA[touch]]></category>

		<guid isPermaLink="false">http://www.unixtutorial.org/?p=146</guid>
		<description><![CDATA[If you remember, all files and directories in Unix filesystems have three timestamps associated with them - atime, ctime and mtime. Since questions about modifying access time (atime) and modification time (mtime) are quite frequent in my website logs, I thought I'd explain how it is done.
How to view atime, ctime and mtime
Before we go [...]]]></description>
			<content:encoded><![CDATA[<p>If you remember, all files and directories in Unix filesystems have three timestamps associated with them - <a title="atime, ctime and mtime" href="http://www.unixtutorial.org/2008/04/atime-ctime-mtime-in-unix-filesystems/">atime, ctime and mtime</a>. Since questions about modifying access time (atime) and modification time (mtime) are quite frequent in my website logs, I thought I'd explain how it is done.</p>
<h3>How to view atime, ctime and mtime</h3>
<p>Before we go any further, I'd like to remind you that using stat command is probably the easiest way to look at all the three timestamps associated with each file:</p>
<pre>ubuntu$ <strong>stat ./try</strong>
  File: `./try'
  Size: 0               Blocks: 0          IO Block: 4096   regular empty file
Device: 801h/2049d      Inode: 655596      Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1000/   greys)   Gid: (  113/   admin)
Access: 2008-11-17 05:01:16.000000000 -0600
Modify: 2008-11-17 05:01:16.000000000 -0600
Change: 2008-11-17 05:01:16.000000000 -0600</pre>
<p>Even though <a title="ls directory listing" href="http://www.unixcommand.org/ls">ls command</a> can be used to view the same times, we will depend on the stat command for today's post simply because it shows all the times together - it's great for explanations.</p>
<h3>Modifying atime and mtime</h3>
<p>There's a very simple way to update either atime or mtime for a given file, or even both at the same time: you should use the <a title="touch unix command" href="http://www.unixcommand.org/touch"><strong>touch command</strong></a>.</p>
<p>Here's how it can be used to update the atime:</p>
<pre>ubuntu$ <strong>touch -at 0711171533 ./try</strong></pre>
<p>The <strong>-a</strong> in the command line parameters refers to atime, while <strong>-t</strong> and the following sequence are nothing but a timestamp we want assigned to the file.</p>
<p>In my example, 0711171533 means this:</p>
<ul>
<li>07 - year of 2007</li>
<li>11 - November</li>
<li>17 - 17th</li>
<li>1533 - time of the day, 15:33</li>
</ul>
<p>Now, if we run stat command again, you can see how the access time field got updated:</p>
<pre>ubuntu$ <strong>stat ./try</strong>
  File: `./try'
  Size: 0               Blocks: 0          IO Block: 4096   regular empty file
Device: 801h/2049d      Inode: 655596      Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1000/   greys)   Gid: (  113/   admin)
Access: 2007-11-17 15:33:00.000000000 -0600
Modify: 2008-11-17 05:01:16.000000000 -0600
Change: 2008-11-17 05:01:48.000000000 -0600</pre>
<p>Similarly,  we can set the mtime, in my particular example it's the future - a day exactly one year from now. <strong>-m</strong> is the command line option to specify that mtime is our main focus:</p>
<pre>ubuntu$ <strong>touch -mt 0911171533 ./try</strong>
ubuntu$ <strong>stat ./try</strong>
  File: `./try'
  Size: 0               Blocks: 0          IO Block: 4096   regular empty file
Device: 801h/2049d      Inode: 655596      Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1000/   greys)   Gid: (  113/   admin)
Access: 2007-11-17 15:33:00.000000000 -0600
Modify: 2009-11-17 15:33:00.000000000 -0600
Change: 2008-11-17 05:05:41.000000000 -0600</pre>
<h3>Changing atime and mtime to the current Unix time</h3>
<p>It's probably useful to know that the default behavior of the <a title="touch" href="http://www.unixcommand.org/touch">touch command</a> is to update both access time and modification time of a file, changing them to the current time on your system.</p>
<p>Here's what will happen if I run touch against the same file we used in all the examples:</p>
<pre>ubuntu$ <strong>touch ./try</strong>
ubuntu$ <strong>stat ./try</strong>
  File: `./try'
  Size: 0               Blocks: 0          IO Block: 4096   regular empty file
Device: 801h/2049d      Inode: 655596      Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1000/   greys)   Gid: (  113/   admin)
Access: 2008-11-17 05:09:33.000000000 -0600
Modify: 2008-11-17 05:09:33.000000000 -0600
Change: 2008-11-17 05:09:33.000000000 -0600</pre>
<p>As you can see, all three fields have been reset to the new (current time) value.</p>
<p>That's it for today, I hope this solved another one of your Unix mysteries!</p>
<h3>See also:</h3>
<ul>
<li><strong><a title="atime mtime ctime unix" href="http://www.unixtutorial.org/2008/04/atime-ctime-mtime-in-unix-filesystems/">atime, ctime and mtime in Unix</a></strong></li>
<li><strong><a title="file permissions unix perl" href="http://www.unixtutorial.org/2008/02/file-type-and-permissions-in-perl/">find out file permissions using Perl script</a></strong></li>
<li><strong><a title="time and date" href="http://www.unixtutorial.org/2008/06/unix-scripting-time-and-date/">time and date in Unix scripts</a><br />
</strong></li>
</ul>
<img src="http://feeds.feedburner.com/~r/UnixTutorial/~4/455938341" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.unixtutorial.org/2008/11/how-to-update-atime-and-mtime-for-a-file-in-unix/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.unixtutorial.org/2008/11/how-to-update-atime-and-mtime-for-a-file-in-unix/</feedburner:origLink></item>
		<item>
		<title>Today Only: Grab Your 100% Free Copy of CrossOver Pro</title>
		<link>http://feeds.feedburner.com/~r/UnixTutorial/~3/434524306/</link>
		<comments>http://www.unixtutorial.org/2008/10/free-copy-of-crossover-pro/#comments</comments>
		<pubDate>Tue, 28 Oct 2008 09:31:17 +0000</pubDate>
		<dc:creator>Gleb Reys</dc:creator>
		
		<category><![CDATA[News]]></category>

		<category><![CDATA[codeweavers]]></category>

		<category><![CDATA[crossover]]></category>

		<category><![CDATA[emulation]]></category>

		<category><![CDATA[wine]]></category>

		<guid isPermaLink="false">http://www.unixtutorial.org/?p=130</guid>
		<description><![CDATA[CodeWeavers are giving their award-winning CrossOver software for free.
What is CrossOver?
CrossOver is a tweaked and polished, proprietary version of Wine - an implementation of Windows API for Unix. Simply put, it's a software which allows you to run Windows applications on your Unix system. Wine, especially since the 1.0 release, is quite a pleasant and [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.codeweavers.com">CodeWeavers</a> are giving their award-winning <a href="http://lameduck.codeweavers.com/free/">CrossOver software for free</a>.</p>
<h3>What is CrossOver?</h3>
<p>CrossOver is a tweaked and polished, proprietary version of Wine - an implementation of Windows API for Unix. Simply put, it's a software which allows you to run Windows applications on your Unix system. Wine, especially since the 1.0 release, is quite a pleasant and reliable way of running Windows software on your Unix desktop, but CrossOver is known for putting many more tweaks on top of the features implemented in Wine, mostly to make popular office packages (Microsoft Office) and games work even better in emulated environment.</p>
<h3>CrossOver Pro For Free</h3>
<p>For one day only, <strong>October 28th 2008</strong>, you can go to the <a href="http://www.codeweavers.com">CodeWeavers</a> website to request your free registration key for the professional version of their CrossOver software suite - either for Linux or Mac. These are fully functional serial keys for the pro version, technical support included.</p>
<p>The trick is that <em>you need to have this key activated as soon as possible! </em>Originally, you were only given time until midnight, but it is now promised that you'll get another 48hours to activate your key, although <em>free registration keys will stop after 23:59 PM Central Standard Time</em><em>. </em></p>
<p>Wait no more - the main <a href="http://www.codeweavers.com">CodeWeavers</a> website is already down due to traffic, but <a href="http://lameduck.codeweavers.com/free/">Free CrossOver Pro</a> registration form is still available!</p>
<h3>See also:</h3>
<ul>
<li><a href="http://www.codeweavers.com/">CodeWeavers website</a></li>
<li><a href="http://en.wikipedia.org/wiki/CrossOver">CrossOver @ Wikipedia</a></li>
<li><a href="http://www.winehq.org/">Wine HQ</a></li>
</ul>
<img src="http://feeds.feedburner.com/~r/UnixTutorial/~4/434524306" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.unixtutorial.org/2008/10/free-copy-of-crossover-pro/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.unixtutorial.org/2008/10/free-copy-of-crossover-pro/</feedburner:origLink></item>
		<item>
		<title>Tracking the Progress of  Rsync Transfers</title>
		<link>http://feeds.feedburner.com/~r/UnixTutorial/~3/409432208/</link>
		<comments>http://www.unixtutorial.org/2008/10/tracking-the-progress-of-rsync-transfers/#comments</comments>
		<pubDate>Thu, 02 Oct 2008 17:09:57 +0000</pubDate>
		<dc:creator>Gleb Reys</dc:creator>
		
		<category><![CDATA[Linux]]></category>

		<category><![CDATA[Unix]]></category>

		<category><![CDATA[rsync]]></category>

		<guid isPermaLink="false">http://www.unixtutorial.org/?p=121</guid>
		<description><![CDATA[In my first introductory rsync post, How To Synchronize Directories with Rsync, I've shown you the most basic approach to syncing two directories up. Today, I'd like to show you another useful thing you can do with rsync.
Just to remind you all, rsync is a remote synchronization tool. This means that its primary use lies [...]]]></description>
			<content:encoded><![CDATA[<p>In my first introductory <strong>rsync </strong>post, <strong><a title="synchronize directories with rsync" href="http://www.unixtutorial.org/2008/09/how-to-synchronize-directories-with-rsync/">How To Synchronize Directories with Rsync</a></strong>, I've shown you the most basic approach to syncing two directories up. Today, I'd like to show you another useful thing you can do with <strong>rsync</strong>.</p>
<p>Just to remind you all,<strong> rsync </strong>is a <em><strong>r</strong>emote <strong>sync</strong>hronization</em> tool. This means that its primary use lies in the filed of synchronizing files and directories between remote Unix systems, but I feel that it's really important for you to understand the basics before moving on to more advanced stuff.</p>
<p>The beauty of <strong>rsync </strong>is that its syntax and command line options are exactly the same for local and remote directories synchronizations, so it's not like you'll have to learn it all from scratch when I show you the real world usage of <strong>rsync </strong>in my next post.</p>
<h3><strong>rsync experiments setup</strong></h3>
<p>Just use the following commands to re-create your rsync playground for this post:</p>
<pre><strong>ubuntu$</strong> rm -rf /tmp/dir1 /tmp/dir2
<strong>ubuntu$</strong> mkdir /tmp/dir1 /tmp/dir2
<strong>ubuntu$</strong> cd /tmp
<strong>ubuntu$</strong> echo "original file 1" &gt; dir1/file1
<strong>ubuntu$</strong> echo "original file 2" &gt; dir1/file2
<strong>ubuntu$</strong> echo "original file 3" &gt; dir1/file3
<strong>ubuntu$ </strong>cp dir1/file1 dir2</pre>
<p>It will probably be more convenient for you to just download the same commands in form of a script though, so here's the link: <a title="rsync setup script" href="http://www.unixtutorial.org/examples/rsync-setup.sh">rsync-setup.sh</a></p>
<h3>Tracking rsync progress</h3>
<p>The larger the directories you're synchronizing with rsync, the longer it will take for the command to finish. Depending on the scale of your task, it can be minutes, long hours or even days before you get the synchronization complete. With this in mind, the importance of progress tracking with rsync should be obvious to you.</p>
<p>Here's how you make <strong>rsync </strong>report its progress: just use the <strong>&#8211;progress</strong> command line option (in addition to the command line I introduced you to last time):</p>
<pre>ubuntu$ <strong>rsync -avz --stats --progress /tmp/dir1/ /tmp/dir2</strong>
building file list ...
4 files to consider
file2
          16 100%    0.00kB/s    0:00:00 (xfer#1, to-check=1/4)
file3
          16 100%   15.62kB/s    0:00:00 (xfer#2, to-check=0/4)</pre>
<pre>Number of files: 4
Number of files transferred: 2
Total file size: 48 bytes
Total transferred file size: 32 bytes
Literal data: 32 bytes
Matched data: 0 bytes
File list size: 59
File list generation time: 0.001 seconds
File list transfer time: 0.000 seconds
Total bytes sent: 193
Total bytes received: 64</pre>
<pre>sent 193 bytes  received 64 bytes  514.00 bytes/sec
total size is 48  speedup is 0.19</pre>
<h3><strong>Why you should track the progress of rsyncs</strong></h3>
<p>The key differences are that you first get a regularly updated message about building a file list. When you run into hundreds of thousands of files, this becomes quite useful:</p>
<pre>building file list ...
4 files to consider</pre>
<p>Another way to track progress is to see the transfer progress for each of the involved files. For thousands tiny files it won't be all that impressive a feature, but if you're transferring huge files between remote systems, a dynamic transfer progress for each file will be exactly what you need:</p>
<pre>file2
          16 100%    0.00kB/s    0:00:00 (xfer#1, to-check=1/4)
file3
          16 100%   15.62kB/s    0:00:00 (xfer#2, to-check=0/4)</pre>
<p>That's it, hope you like this new option. I promise to tell you more some other time!</p>
<h3>See also:</h3>
<ul>
<li><strong><a title="rsync synchronization" href="http://www.unixtutorial.org/2008/09/how-to-synchronize-directories-with-rsync/">Synchronize Directories in Unix with rsync command</a></strong></li>
<li><strong><a title="How to compare Unix directories" href="http://www.unixtutorial.org/2008/06/how-to-compare-directories-in-unix/">Comparing directories in Unix</a></strong></li>
<li><strong><a title="How to find large files and directories" href="http://www.unixtutorial.org/2008/03/find-large-files-and-directories/">Finding large files and directories</a><br />
</strong></li>
</ul>
<img src="http://feeds.feedburner.com/~r/UnixTutorial/~4/409432208" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.unixtutorial.org/2008/10/tracking-the-progress-of-rsync-transfers/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.unixtutorial.org/2008/10/tracking-the-progress-of-rsync-transfers/</feedburner:origLink></item>
		<item>
		<title>How To Remove Files and Directories with Special Characters</title>
		<link>http://feeds.feedburner.com/~r/UnixTutorial/~3/403126546/</link>
		<comments>http://www.unixtutorial.org/2008/09/remove-files-and-directories-with-special-characters/#comments</comments>
		<pubDate>Thu, 25 Sep 2008 20:35:35 +0000</pubDate>
		<dc:creator>Gleb Reys</dc:creator>
		
		<category><![CDATA[Basic stuff]]></category>

		<guid isPermaLink="false">http://www.unixtutorial.org/?p=114</guid>
		<description><![CDATA[Today is going to be a practical tip. If you're managing many Unix systems, sooner or later you come across files with special characters - they can't be deleted with rm command using standard approach and require a bit of trickery to be successfully removed.
Examples of files with special characters
Any language apart from English will [...]]]></description>
			<content:encoded><![CDATA[<p>Today is going to be a practical tip. If you're managing many Unix systems, sooner or later you come across files with special characters - they can't be deleted with <strong>rm </strong>command using standard approach and require a bit of trickery to be successfully removed.</p>
<h3>Examples of files with special characters</h3>
<p>Any language apart from English will probably have special characters in the alphabet, but for the purpose of today's exercise I'll give you more standard examples: files starting with dash (-) and hash (#) characters:</p>
<pre>ubuntu$ <strong>ls -al</strong>
-rw-r--r-- 1 greys admin    0 Sep 25 05:50 #try
-rw-r--r-- 1 greys admin    0 Sep 25 05:48 -try</pre>
<p>Now, if you try to access these files or remove them, you will get errors:</p>
<pre>ubuntu$ <strong>cat -try</strong>
cat: invalid option -- r
Try `cat --help' for more information.
ubuntu$ <strong>rm -try</strong>
rm: invalid option -- t
Try `rm ./-try' to remove the file `-try'.
Try `rm --help' for more information.</pre>
<p>These errors happen because commands treat file names as command line options because they start with dash (-).</p>
<p>With filenames starting with hash (#), you'll get a different kind of error: your Unix shell will treat the rest of a filename (and anything that might follow it) as a comment because hashes are used to do it in shell scripts. That's why your cat command will not show any error but will not finish until you Ctrl+C it:</p>
<pre>ubuntu$ <strong>cat #try</strong></pre>
<p>&#8230; and if you try removing such a file, you'll get a complaint from the <strong>rm </strong>command about missing command line parameters - because of the hash (#) sign, <strong>rm </strong>command receives no text as a parameter:</p>
<pre>ubuntu$ <strong>rm #try</strong>
rm: missing operand
Try `rm --help' for more information.</pre>
<h3>How to remove a file when filename starts with dash (-)</h3>
<p>First I'm gonna show you how to make your Unix shell interpret any filename directly instead of trying to analyze it as a set of command line options.</p>
<p>To make command ignore the leading dash (-) in a filename, use the &#8212; command line option:</p>
<pre>ubuntu$ <strong>rm -- -try</strong></pre>
<p>As you can see, our file is gone:</p>
<pre>ubuntu$ <strong>ls -al</strong>
-rw-r--r-- 1 greys admin    0 Sep 25 05:50 #try</pre>
<h3>Using backslash to escape special characters in a filename</h3>
<p>Another option we have is to use a backslash (\), which will make shell interpreter ignore the special functionality of a character which immediately follows it. To escape the hash (#) our second file has, we should therefore do the following:</p>
<pre>ubuntu$ <strong>rm \#try</strong></pre>
<p><strong>Interesting to know:</strong> bash shell has an auto-completion functionality built in. When you type a filename, just press Tab key to make it auto-complete the name for you. Speaking of special characters in particular, quite a few of them are recognized by auto-completion and get escaped automatically.</p>
<p>So, if you start typing:</p>
<pre>ubuntu $ <strong>rm #t</strong></pre>
<p>&#8230; and then press Tab, bash will not only auto-complete the name, but escape the leading hash (#):</p>
<p>ubuntu $ <strong>rm \#try</strong></p>
<p>There's a few more tricks you can use for escaping special characters, but they're worth a separate post, so stay tuned! Until then, enjoy getting rid of annoying files with special characters in filenames!</p>
<h3>See also:</h3>
<ul>
<li><strong><a title="math expressions in unix" href="http://www.unixtutorial.org/2008/09/math-expressions-in-unix-scripts/">Using math expressions in Unix shell</a></strong></li>
<li><strong><a title="Updating variables in Unix" href="http://www.unixtutorial.org/2008/08/updating-values-of-your-shell-variables-in-unix/">Updating shell variables in Unix</a></strong></li>
<li><strong><a title="parsing text in shell" href="http://www.unixtutorial.org/2008/08/how-to-parse-text-files-line-by-line-in-unix-scripts/">Parsing text in Unix shell</a><br />
</strong></li>
</ul>
<img src="http://feeds.feedburner.com/~r/UnixTutorial/~4/403126546" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.unixtutorial.org/2008/09/remove-files-and-directories-with-special-characters/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.unixtutorial.org/2008/09/remove-files-and-directories-with-special-characters/</feedburner:origLink></item>
		<item>
		<title>Interesting Reads - Sep 21st, 2008</title>
		<link>http://feeds.feedburner.com/~r/UnixTutorial/~3/398821235/</link>
		<comments>http://www.unixtutorial.org/2008/09/interesting-reads-sep-21st-2008/#comments</comments>
		<pubDate>Sun, 21 Sep 2008 10:34:22 +0000</pubDate>
		<dc:creator>Gleb Reys</dc:creator>
		
		<category><![CDATA[News]]></category>

		<guid isPermaLink="false">http://www.unixtutorial.org/?p=111</guid>
		<description><![CDATA[Here are the posts I've read and enjoyed this week:

sshpass - automating SSH logins without passwordless RSA/DSA keys
Tux Training: Get rid of command line histories with chattr command
Tux Training: Speeding up your ext3 filesystem

If you have any useful articles you'd like to share - just leave links in the comments area. Enjoy!
]]></description>
			<content:encoded><![CDATA[<p>Here are the posts I've read and enjoyed this week:</p>
<ul>
<li><a href="http://www.cyberciti.biz/faq/noninteractive-shell-script-ssh-password-provider/">sshpass - automating SSH logins without passwordless RSA/DSA keys</a></li>
<li><a href="http://tuxtraining.com/2008/09/09/using-chattr-to-eliminate-command-line-histories/">Tux Training: Get rid of command line histories with chattr command</a></li>
<li><a href="http://tuxtraining.com/2008/09/08/speed-up-your-ext3-file-system/">Tux Training: Speeding up your ext3 filesystem</a></li>
</ul>
<p>If you have any useful articles you'd like to share - just leave links in the comments area. Enjoy!</p>
<img src="http://feeds.feedburner.com/~r/UnixTutorial/~4/398821235" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.unixtutorial.org/2008/09/interesting-reads-sep-21st-2008/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.unixtutorial.org/2008/09/interesting-reads-sep-21st-2008/</feedburner:origLink></item>
		<item>
		<title>Easy date calculations in Unix scripts with GNU date</title>
		<link>http://feeds.feedburner.com/~r/UnixTutorial/~3/397225796/</link>
		<comments>http://www.unixtutorial.org/2008/09/easy-date-calculations-in-unix-scripts-with-gnu-date/#comments</comments>
		<pubDate>Fri, 19 Sep 2008 13:53:10 +0000</pubDate>
		<dc:creator>Gleb Reys</dc:creator>
		
		<category><![CDATA[Basic stuff]]></category>

		<category><![CDATA[Scripts]]></category>

		<guid isPermaLink="false">http://www.unixtutorial.org/?p=107</guid>
		<description><![CDATA[When I was writing a post about using date command to confirm date and time in your Unix scripts, I made a note in my future posts list to cover the date calculations - finding out the date of yesterday or tomorrow, and so on. Today I'll show you the simplest way to calculate this.

GNU [...]]]></description>
			<content:encoded><![CDATA[<p>When I was writing a post about <a title="time and date in Unix" href="http://www.unixtutorial.org/2008/06/unix-scripting-time-and-date/">using date command to confirm date and time in your Unix scripts</a>, I made a note in my future posts list to cover the date calculations - finding out the date of yesterday or tomorrow, and so on. Today I'll show you the simplest way to calculate this.</p>
<h3></h3>
<h3>GNU date command advantage</h3>
<p>GNU version of the <strong>date</strong> command, although supporting a common syntax, has one great option: it allows you to specify the desired date with a simple string before reporting it back. What this means is that by default this specified date is assumed to be "now", but you can use other keywords to shift the result of the date command and thus show what date it was yesterday or a week ago:</p>
<p>Here's a default <strong>date</strong> output for the current date and time:</p>
<pre>ubuntu$ <strong>date</strong>
Fri Sep 19 08:06:41 CDT 2008</pre>
<p>Now, the parameter for specifying desired date is <strong>-d</strong> or <strong>&#8211;date</strong>, and if you use it with the "now" or "today" parameter, you'll get similar output:</p>
<pre>ubuntu$ <strong>date -d now</strong>
Fri Sep 19 08:06:44 CDT 2008
ubuntu$ <strong>date -d today</strong>
Fri Sep 19 08:06:50 CDT 2008</pre>
<h3>Showing tomorrow's date</h3>
<p>Similarly, you can get tomorrow's date:</p>
<pre>ubuntu$ <strong>date -d tomorrow</strong>
Sat Sep 20 08:02:12 CDT 2008</pre>
<p>Obviously, if you feel like specifying a format for the date, you can do it:</p>
<pre>ubuntu$ <strong>date -d tomorrow "+%b %d, %Y"</strong>
Sep 20, 2008</pre>
<h3>Find out yesterday's date</h3>
<p>Again, there's no rocket science involved in showing yesterday's date neither:</p>
<pre>ubuntu$ <strong>date -d yesterday "+%b %d, %Y"</strong>
Sep 18, 2008</pre>
<h3>Show a date few days away</h3>
<p>If you're interested in a certain date a few days or even weeks away, here's how you can do it:</p>
<h4>Example 1: a date 5 days ago</h4>
<pre>ubuntu$ <strong>date -d "-5 days"</strong>
Sun Sep 14 08:45:57 CDT 2008</pre>
<h4>Example 2: a day 2 weeks from now</h4>
<pre>ubuntu$ <strong>date -d "2 weeks"</strong>
Fri Oct  3 08:45:08 CDT 2008</pre>
<h4>Example 3: a day two weeks ago from now</h4>
<pre>ubuntu$ <strong>date -d "-2 weeks"</strong>
Fri Sep  5 08:45:11 CDT 2008</pre>
<h4>Extreme example: a day 50 years ago</h4>
<p>If you're really curious about dates in Unix, you can even make GNU date go back a few years:</p>
<pre>ubuntu$ <strong>date -d "-50 years"</strong>
Fri Sep 19 08:47:51 CDT 1958</pre>
<p>That's it for today, hope you like this little discovery - having mostly worked with Solaris systems most of my career, I didn't know my Ubuntu had this functionality bonus. Really useful!</p>
<h3>See also:</h3>
<ul>
<li><strong><a title="Unix date" href="http://www.unixtutorial.org/2008/06/unix-scripting-time-and-date/">Time and date in Unix scripts</a></strong></li>
<li><strong><a title="shell scripting - variables" href="http://www.unixtutorial.org/2008/05/variables-in-unix-shell/">Variables in Unix shell scripts</a><br />
</strong></li>
<li><strong><a title="updating variables" href="http://www.unixtutorial.org/2008/08/updating-values-of-your-shell-variables-in-unix/">Updating shell variables in Unix</a><br />
</strong></li>
</ul>
<img src="http://feeds.feedburner.com/~r/UnixTutorial/~4/397225796" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.unixtutorial.org/2008/09/easy-date-calculations-in-unix-scripts-with-gnu-date/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.unixtutorial.org/2008/09/easy-date-calculations-in-unix-scripts-with-gnu-date/</feedburner:origLink></item>
		<item>
		<title>Another way to use math expressions in shell scripts</title>
		<link>http://feeds.feedburner.com/~r/UnixTutorial/~3/395713472/</link>
		<comments>http://www.unixtutorial.org/2008/09/math-expressions-in-unix-scripts/#comments</comments>
		<pubDate>Thu, 18 Sep 2008 00:43:06 +0000</pubDate>
		<dc:creator>Gleb Reys</dc:creator>
		
		<category><![CDATA[Basic stuff]]></category>

		<category><![CDATA[Scripts]]></category>

		<category><![CDATA[Unix]]></category>

		<guid isPermaLink="false">http://www.unixtutorial.org/?p=105</guid>
		<description><![CDATA[Today I'd like to expand a bit more on the basic calculations in Unix scripts.
Use Parenthesis to simplify math expressions
In Basic Arithmetic Operations post I've shown you how expression evaluation can be used to calculate simple math expressions in your Unix shell:
ubuntu$ START=1
ubuntu$ FINISH=10
ubuntu$ ELAPSED=$(($FINISH - $START))
ubuntu$ echo $ELAPSED
9
Although this approach looks clean enough, there's [...]]]></description>
			<content:encoded><![CDATA[<p>Today I'd like to expand a bit more on the basic calculations in Unix scripts.</p>
<h3>Use Parenthesis to simplify math expressions</h3>
<p>In <a title="Basic arithmetic operations in scripts" href="http://www.unixtutorial.org/2008/06/arithmetic-operations-in-unix-scripts/">Basic Arithmetic Operations post</a> I've shown you how expression evaluation can be used to calculate simple math expressions in your Unix shell:</p>
<pre>ubuntu$ <strong>START=1</strong>
ubuntu$ <strong>FINISH=10</strong>
ubuntu$ <strong>ELAPSED=$(($FINISH - $START))</strong>
ubuntu$ <strong>echo $ELAPSED</strong>
9</pre>
<p>Although this approach looks clean enough, there's a way to simplify it even further if you put everything in parenthesis. In other words, the same result (ELAPSED receiving a correct value of FINISH value minus START value) can be achieved this way:</p>
<pre>ubuntu$ <strong>((ELAPSED=FINISH-START))</strong>
ubuntu$ <strong>echo $ELAPSED</strong>
9</pre>
<p>It's a matter of preference, and I used to always do such calculations the former way shown, but now that one of the readers of this blog pointed out the latter way of using it, I think I might change my habits - I actually like this way much better.</p>
<h3>See also:</h3>
<ul>
<li><strong><a title="Unix Scripts: time and date" href="http://www.unixtutorial.org/2008/06/unix-scripting-time-and-date/">Time and date in Unix scripts</a></strong></li>
<li><strong><a title="Variables in Unix scripts" href="http://www.unixtutorial.org/2008/05/variables-in-unix-shell/">Using variables in scripts</a><br />
</strong></li>
<li><strong><a title="Basic math in scripts" href="http://www.unixtutorial.org/2008/05/variables-in-unix-shell/">Basic math in Unix scripts</a></strong></li>
</ul>
<img src="http://feeds.feedburner.com/~r/UnixTutorial/~4/395713472" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.unixtutorial.org/2008/09/math-expressions-in-unix-scripts/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.unixtutorial.org/2008/09/math-expressions-in-unix-scripts/</feedburner:origLink></item>
		<item>
		<title>Follow me on Twitter!</title>
		<link>http://feeds.feedburner.com/~r/UnixTutorial/~3/386445468/</link>
		<comments>http://www.unixtutorial.org/2008/09/follow-me-on-twitter/#comments</comments>
		<pubDate>Mon, 08 Sep 2008 07:18:28 +0000</pubDate>
		<dc:creator>Gleb Reys</dc:creator>
		
		<category><![CDATA[News]]></category>

		<guid isPermaLink="false">http://www.unixtutorial.org/?p=100</guid>
		<description><![CDATA[
It was bound to happen: I've joined Twitter! It would be great to hear from you there!
Follow me or leave your Twitter name in comments below so that I can follow you:
http://twitter.com/PerfectBlogger
Also, if you happen to know some interesting Twitter feeds for all of us interested in Unix-like systems, leave links to them as well!
See [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><a href="http://www.perfectblogger.com/images/2008/09/twitter.png"><img class="size-full wp-image-210 aligncenter" title="twitter" src="http://www.perfectblogger.com/images/2008/09/twitter.png" alt="" width="210" height="49" /></a></p>
<p>It was bound to happen: I've joined <a href="http://www.twitter.com">Twitter</a>! It would be great to hear from you there!</p>
<p>Follow me or leave your Twitter name in comments below so that I can follow you:</p>
<p><a title="Perfect Blogger @ Twitter" href="http://twitter.com/PerfectBlogger">http://twitter.com/PerfectBlogger</a></p>
<p>Also, if you happen to know some interesting Twitter feeds for all of us interested in Unix-like systems, leave links to them as well!</p>
<h3>See also:</h3>
<ul>
<li><strong><a href="http://www.unixtutorial.org/2008/08/how-to-use-this-website/">How to use this website</a></strong></li>
<li><strong><a href="http://www.unixtutorial.org/contact/">Contact Unix Tutorial</a></strong></li>
<li><strong><a href="http://www.twitter.com">Official Twitter website</a><br />
</strong></li>
</ul>
<img src="http://feeds.feedburner.com/~r/UnixTutorial/~4/386445468" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.unixtutorial.org/2008/09/follow-me-on-twitter/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.unixtutorial.org/2008/09/follow-me-on-twitter/</feedburner:origLink></item>
		<item>
		<title>How To Synchronize Directories with Rsync</title>
		<link>http://feeds.feedburner.com/~r/UnixTutorial/~3/383099241/</link>
		<comments>http://www.unixtutorial.org/2008/09/how-to-synchronize-directories-with-rsync/#comments</comments>
		<pubDate>Thu, 04 Sep 2008 09:05:25 +0000</pubDate>
		<dc:creator>Gleb Reys</dc:creator>
		
		<category><![CDATA[Basic stuff]]></category>

		<guid isPermaLink="false">http://www.unixtutorial.org/?p=89</guid>
		<description><![CDATA[Today I’d like to show you the basic usage of rsync – a wonderful, old and reliable tool for incremental data transfers and synchronization of local directories or even data between different Unix systems.
rsync is quite a complicated command, so don’t expect this first post to explain everything and cover every possibility. Like I said, [...]]]></description>
			<content:encoded><![CDATA[<p>Today I’d like to show you the basic usage of <strong>rsync </strong>– a wonderful, old and reliable tool for incremental data transfers and synchronization of local directories or even data between different Unix systems.</p>
<p><strong>rsync </strong>is quite a complicated command, so don’t expect this first post to explain everything and cover every possibility. Like I said, this is only the beginning.</p>
<h3>What is rsync?</h3>
<p><strong>rsync </strong>(stands for <em><strong>r</strong>emote <strong>sync</strong>hronization</em>) is an open source tool for data transfers between Unix systems.</p>
<p>In simplest form, it’s just a Unix command you run locally to synchronize two directories. But the real power of rsync is when you need to synchronize directories between remote systems. rsync relies on ssh protocol for transferring the data between Unix systems, but earlier versions used rsh. Advanced deployments imply using rsync server in addition to simply running the command – this is basically the same command but running in a stand-by daemon mode.</p>
<p><strong>rsync </strong>can easily be found or installed in any modern Unix-like OS, but it's always best to check the official website for latest developments around this tool: <a title="rsync" href="http://samba.anu.edu.au/rsync/">rsync website</a>.</p>
<h3>What does rsync do?</h3>
<p>rsync synchronizes directories - makes one directory look (contain the same files and subdirectories) exactly like another one. rsync works by getting a list of files in your source and destination directories, comparing them as per specified criteria (file size, creation/modification date or checksum) and then making the destination directory reflect all the changes which happened to the source since the last synchronization session.</p>
<h3>Basic rsync usage</h3>
<p>Just to show you how it works, I’m going to create two directories with a few files in them. <strong>/tmp/dir1</strong> in my examples will be a source directory (original dataset), while <strong>/tmp/dir2</strong> will be a destination directory - to be made the same as /tmp/dir1 as the result of running rsync.</p>
<p>So that's how I set up directories and files:</p>
<pre>ubuntu$ <strong>mkdir /tmp/dir1 /tmp/dir2</strong>
ubuntu$ <strong>cd /tmp</strong>
ubuntu$ <strong>echo "original file 1" &gt; dir1/file1</strong>
ubuntu$ <strong>echo "original file 2" &gt; dir1/file2</strong>
ubuntu$ <strong>echo "original file 3" &gt; dir1/file3</strong>
ubuntu$ <strong>cp dir1/file1 dir2</strong></pre>
<p>That's how our directories and files look now, so dir2 contains a copy of file1:</p>
<pre>ubuntu$ <strong>find ./dir*</strong>
./dir1
./dir1/file2
./dir1/file3
./dir1/file1
./dir2
./dir2/file1</pre>
<p>Now it's time to run your first ever rsync. There's two ways of specifying options for the command, a full option name starting with &#8212; and usually having a meaningful name, or a short option name - starting with - and having short meaningless names (usually one-letter ones) for each option.</p>
<p>The last two parameters in an rsync command line should be the source and the destination directories.</p>
<p>In this example below, we're using the following options:</p>
<p><strong>-avz</strong> - a for archive mode (preserve all the attributes of each file and directory - ownership, permissions, etc), v for verbose mode (report a list of files processed by rsync) and z for data compression to speed transfers up.</p>
<p><strong>&#8211;stats</strong> - this option shows a summary at the end of rsync'ing process to highlight the main stats of the job</p>
<pre>ubuntu$ <strong>rsync -avz --stats  /tmp/dir1/ /tmp/dir2</strong>
building file list ... done
file2
file3

Number of files: 4
Number of files transferred: 2
Total file size: 48 bytes
Total transferred file size: 32 bytes
Literal data: 32 bytes
Matched data: 0 bytes
File list size: 87
File list generation time: 0.001 seconds
File list transfer time: 0.000 seconds
Total bytes sent: 221
Total bytes received: 64

sent 221 bytes  received 64 bytes  570.00 bytes/sec
total size is 48  speedup is 0.17</pre>
<p>Stats are self-explanatory, and you can see that although there were 4 files found in source directory /tmp/dir1, only 2 files were transferred into /tmp/dir2 because /tmp/dir2 already had one of the files.</p>
<p>That’s all I have for you today, in the next post on rsync I’ll show you some more advanced uses of this command. For the time being, read <strong>man rsync</strong> or even <strong>rsync &#8211;help</strong> on your system to get an idea of how really powerful this tool is.</p>
<p>Until next time – good luck with your Unix experiments!</p>
<h3>See also:</h3>
<ul>
<li><strong><a title="compare directories in Unix" href="http://www.unixtutorial.org/2008/06/how-to-compare-directories-in-unix/">How to compare directories in Unix</a></strong></li>
<li><strong><a title="directory and subdirectories" href="http://www.unixtutorial.org/2008/04/how-to-list-directories-in-a-directory-in-unix/">List subdirectories of a Unix directory</a></strong></li>
<li><strong><a title="large files in Unix" href="http://www.unixtutorial.org/2008/03/find-large-files-and-directories/">Finding large files and directories</a><br />
</strong></li>
</ul>
<img src="http://feeds.feedburner.com/~r/UnixTutorial/~4/383099241" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.unixtutorial.org/2008/09/how-to-synchronize-directories-with-rsync/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.unixtutorial.org/2008/09/how-to-synchronize-directories-with-rsync/</feedburner:origLink></item>
	</channel>
</rss>
