<?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>wp &#124; anoopdotnet &#187; Technobabble</title>
	<atom:link href="http://wp.anoop.net/category/technobabble/feed/" rel="self" type="application/rss+xml" />
	<link>http://wp.anoop.net</link>
	<description>yet another meaningless wordpress blog</description>
	<lastBuildDate>Fri, 26 Mar 2010 03:51:43 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Handy mkdir, rm, ls commands with {}</title>
		<link>http://wp.anoop.net/2009/10/handy-mkdir-rm-ls-commands-with/</link>
		<comments>http://wp.anoop.net/2009/10/handy-mkdir-rm-ls-commands-with/#comments</comments>
		<pubDate>Wed, 28 Oct 2009 00:37:24 +0000</pubDate>
		<dc:creator>Anoop</dc:creator>
				<category><![CDATA[Geekdom]]></category>
		<category><![CDATA[Technobabble]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[ls]]></category>
		<category><![CDATA[mkdir]]></category>
		<category><![CDATA[rm]]></category>
		<category><![CDATA[shell]]></category>

		<guid isPermaLink="false">http://wp.anoop.net/?p=183</guid>
		<description><![CDATA[I always find these commands handy when working with apache. Part of any VirtualHost config involves making the right directories and you can make your job easier by using curly braces. I suppose you could call it regular expressions. I don&#8217;t actually know the technical terms for it. I know it works in bash which [...]]]></description>
			<content:encoded><![CDATA[<p>I always find these commands handy when working with <a href="http://httpd.apache.org/" target="_blank">apache</a>.</p>
<p>Part of any <a href="http://httpd.apache.org/docs/2.0/vhosts/examples.html" target="_blank">VirtualHost</a> config involves making the right directories and you can make your job easier by using curly braces. I suppose you could call it regular expressions. I don&#8217;t actually know the technical terms for it. I know it works in bash which is what I use on a daily basis.</p>
<p>Learn how to create directories without having to issue multiple mkdir commands. This is a pretty simple one.</p>
<blockquote><p>mkdir -p /path/to/some/vhost/docs</p></blockquote>
<p>This is fairly straight forward. Make the parent directories if they don&#8217;t exist. So if <strong>/path/to/some/vhost/docs</strong> is what you want, and <strong>/path</strong> or any of it&#8217;s children don&#8217;t exist, then it will get created. It&#8217;s a fairly safe command because it intelligently checks before creating directories.</p>
<p>This example is a bit more complicated but it&#8217;s awesomeness will blow you away. I used this when I was making virtualhosts for multiple domains or even sub domains of the same parent.</p>
<blockquote><p>mkdir -p {sub1,sub2,sub3}.domain.com/{docs,logs,cgi-bin}</p>
<p>or</p>
<p>mkdir -p www.{domain1,domain2,domain3}.com/{docs,logs,cgi-bin}</p></blockquote>
<p>that command will create all your directories in the appropriate hierarchy so that you don&#8217;t need to issue multiple mkdir commands. It will create the parent directories for you as well. Here is what it does.</p>
<blockquote><p>$ find .<br />
.<br />
./www.domain1.com<br />
./www.domain1.com/cgi-bin<br />
./www.domain1.com/docs<br />
./www.domain1.com/logs<br />
./www.domain2.com<br />
./www.domain2.com/cgi-bin<br />
./www.domain2.com/docs<br />
./www.domain2.com/logs<br />
./www.domain3.com<br />
./www.domain3.com/cgi-bin<br />
./www.domain3.com/docs<br />
./www.domain3.com/logs</p></blockquote>
<p>You can also do that with ls.</p>
<blockquote><p>$ ls -d www.domain{1,2}*<br />
www.domain1.com    www.domain2.com</p></blockquote>
<p>Or even with rm</p>
<blockquote><p>$ rm -vr www.domain{1,3}*<br />
www.domain1.com/cgi-bin<br />
www.domain1.com/docs<br />
www.domain1.com/logs<br />
www.domain1.com<br />
www.domain3.com/cgi-bin<br />
www.domain3.com/docs<br />
www.domain3.com/logs<br />
www.domain3.com</p></blockquote>
<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://wp.anoop.net/2009/10/handy-mkdir-rm-ls-commands-with/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting Started with PHP &amp; MySQL I &#8211; Results</title>
		<link>http://wp.anoop.net/2009/09/getting-started-with-php-mysql-i-results/</link>
		<comments>http://wp.anoop.net/2009/09/getting-started-with-php-mysql-i-results/#comments</comments>
		<pubDate>Thu, 24 Sep 2009 03:26:46 +0000</pubDate>
		<dc:creator>Anoop</dc:creator>
				<category><![CDATA[Geekdom]]></category>
		<category><![CDATA[Talks]]></category>
		<category><![CDATA[Technobabble]]></category>
		<category><![CDATA[adobe]]></category>
		<category><![CDATA[aug]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://wp.anoop.net/?p=141</guid>
		<description><![CDATA[So, I got some direct feedback from some folks and for the most part it was good. I ran over my time by a little bit and fudged up some of the pages a bit. So definitely some room for improvement. Peggy says I used the words &#8220;uhh, umm, like, right?&#8221; quite a bit and [...]]]></description>
			<content:encoded><![CDATA[<p>So, I got some direct feedback from some folks and for the most part it was good. I ran over my time by a little bit and fudged up some of the pages a bit. So definitely some room for improvement. Peggy says I used the words &#8220;uhh, umm, like, right?&#8221; quite a bit and that&#8217;s also something to improve upon. I&#8217;d like to think I&#8217;m eloquent but in the heat of the moment, all the control over that just goes out the window.</p>
<p>I didn&#8217;t know we were going to get a room that big actually. The last time I was there, we were cramped in a smaller space. I&#8217;m glad it worked out for us. It&#8217;s also a good thing I brought my mini-displayport to VGA adapter.</p>
<p>Michael Schaffner, who runs the group, said it was great and that he got lots of good comments from the presentation. I quote</p>
<blockquote><p>I just wanted to drop you a brief note to thank you again for last<br />
nights presentation. We have been planning this thing for a long time,<br />
but it was without a doubt worth the wait. I found your presentation<br />
outstanding and the amount of time you put into getting it together<br />
was very apparent. We drew a great crowd and many first time<br />
attendees. It was nice to have someone with such great presentation<br />
skills deliver so much valuable  information. It reflects well on our<br />
group and  guarantees that first timers will return for more. In fact<br />
upon my return home last night I had already received e-mails about<br />
the meeting and registration for next month.</p>
<p>I understand the amount of time and effort it takes to put together a<br />
presentation and I want you to know how much I truly appreciate you<br />
stepping up and volunteering to present. Our group has always been<br />
dependent on the contribution of generous folks like yourself willing<br />
to share.</p></blockquote>
<p>Well, that is just awesome! I felt quite appreciated and I also felt good about myself. Made some new connections and some people who are really trying to get around the PHP &#8220;issue&#8221;. Learning new things is always tough especially when you&#8217;re the only one responsible for learning. No one is pushing you to do it and so it becomes very easy to cast it aside and focus on things you enjoy doing. We&#8217;re all guilty of it. I&#8217;ve been trying to learn Flex and iPhone programming for months now but I prefer the TV it seems more than anything when I get home. We all have uphill battles and some are more difficult to conquer than others. But if you try, I think you&#8217;ll make some progress and it&#8217;s enough to get the ball rolling. That&#8217;s what I learned on Monday night.</p>
<p>I&#8217;m looking forward to doing more presentations to help people and to help myself.</p>
<div id="attachment_143" class="wp-caption alignnone" style="width: 610px"><img class="size-full wp-image-143 " title="31314545" src="http://wp.anoop.net/wp-content/uploads/2009/09/31314545.jpg" alt="Picture from the back of the room from Peggy's Blackberry" width="600" height="450" /><p class="wp-caption-text">Picture from the back of the room from Peggy&#39;s Blackberry</p></div>
<p>That&#8217;s a picture of me (sort of)  basking in the warm glow that the macbook screen emits.</p>
]]></content:encoded>
			<wfw:commentRss>http://wp.anoop.net/2009/09/getting-started-with-php-mysql-i-results/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Getting started with PHP &amp; MySQL I</title>
		<link>http://wp.anoop.net/2009/09/getting-started-with-php-mysql-i/</link>
		<comments>http://wp.anoop.net/2009/09/getting-started-with-php-mysql-i/#comments</comments>
		<pubDate>Sat, 19 Sep 2009 23:46:33 +0000</pubDate>
		<dc:creator>Anoop</dc:creator>
				<category><![CDATA[Geekdom]]></category>
		<category><![CDATA[Talks]]></category>
		<category><![CDATA[Technobabble]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Presentations]]></category>
		<category><![CDATA[public speaking]]></category>

		<guid isPermaLink="false">http://wp.anoop.net/?p=129</guid>
		<description><![CDATA[Normally, I pride myself on public speaking. I&#8217;ve had the privilege of training folks at several of my last jobs but for some reason, today, I feel especially nervous about tomorrows presentation. I volunteered (shoot me now) to present at the Chicago Adobe Users Group on how to get started with using PHP &#38; MySQL. [...]]]></description>
			<content:encoded><![CDATA[<p>Normally, I pride myself on public speaking. I&#8217;ve had the privilege of training folks at several of my last jobs but for some reason, today, I feel especially nervous about tomorrows presentation.</p>
<p>I volunteered (shoot me now) to present at the <a href="http://www.augchicago.org/">Chicago Adobe Users Group</a> on how to get started with using PHP &amp; MySQL. I know there is a misspelling in my name. Don&#8217;t worry about it. The talk is scheduled for Monday, 21st September, 2009. It&#8217;s a great group and the people there are very nice. The person who I spoke to about presenting, Mr. Michael Schaffner, is a very warm person who cares about the people in this group and helping them learn new things and to explore new things. I appreciate that in him a lot as there aren&#8217;t a whole lot of people who care like that these days.</p>
<p>Anyway, I&#8217;ve been working on my presentation and my whole goal is to try and sort of simplify things as much as possible so that the audience is more comfortable asking questions about things that are confusing. Of course, I have no idea if I&#8217;m successful or not. I&#8217;ll find out on Monday.</p>
<p>The example I&#8217;m using is an address book. Of course, no one actually wants to write an address book because those things serve no purpose at all. That&#8217;s what iPhones and addressbook (macosx) are for. But this example will be simple, direct, to the point and quick! That&#8217;s part of the goal too. I want to cover all my material and leave plenty of time for Q&amp;A. Also, I&#8217;m teaching it as I learned it. Baby steps!</p>
<p>Here is my problem. Over the last few years, I&#8217;ve gotten better about my PHP and being around all the developers at work has made me realize the incorrectness of my ways. Now, I find it disturbing to write code that looks messy and is somewhat flawed. Maybe it&#8217;s an evolutionary process. Maybe someone who is just starting off and learning on their own is supposed to write code that has errors but works anyway. The more you write, the better you will become and the better you will become, the better your code will be. Is that possible? I hope it is. If not, this audience is doomed and I will be responsible for all of it.</p>
<p>It is my sincere hope that the group members will consider using a small amount of PHP on their next project and then slowly start using MySQL.</p>
<p>After the presentation, I&#8217;m going to make final tweaks based on the feedback and then post the zipped copy of the code and the presentation up here. Hopefully, my embarrassment will be short lived.</p>
<p>If it is successful, I&#8217;d love to present more talks like</p>
<ul>
<li>PHP &amp;&amp; MySQL II</li>
<li>Building a PHP &amp;&amp; MySQL Development Environment</li>
<li>Flex for beginners (I&#8217;m not great with flex, I&#8217;ve only just begun)</li>
<li>Tomcat for beginners</li>
</ul>
<p>Who knows. I&#8217;m excited and scared at the same time. But maybe that&#8217;s a good sign?</p>
<p>Update: The link if you want to register for it (sorry for the late notice) is at http://augchicagosept2009.eventbrite.com/ but you can find it from the AUGChicago home page too. cheers!</p>
]]></content:encoded>
			<wfw:commentRss>http://wp.anoop.net/2009/09/getting-started-with-php-mysql-i/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Google Voice voicemail transcription/translation?</title>
		<link>http://wp.anoop.net/2009/07/google-voice-voicemail-transcriptiontranslation/</link>
		<comments>http://wp.anoop.net/2009/07/google-voice-voicemail-transcriptiontranslation/#comments</comments>
		<pubDate>Tue, 28 Jul 2009 07:23:49 +0000</pubDate>
		<dc:creator>Anoop</dc:creator>
				<category><![CDATA[Funny]]></category>
		<category><![CDATA[Geekdom]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[Technobabble]]></category>
		<category><![CDATA[google voice]]></category>
		<category><![CDATA[voicemail transcription]]></category>
		<category><![CDATA[voicemail translation]]></category>

		<guid isPermaLink="false">http://wp.anoop.net/?p=105</guid>
		<description><![CDATA[So I was showing Peggy, my lovely girlfriend, the coolness of Google Voice. I asked her to leave me a voicemail on my google voice number and let her watch as it transcribed the messages. Embedded below is what she said and what was transcribed&#8230; What an amazing service! It not only transcribed but also [...]]]></description>
			<content:encoded><![CDATA[<p>So I was showing Peggy, my lovely girlfriend, the coolness of <a href="http://google.com/voice">Google Voice</a>. I asked her to leave me a voicemail on my google voice number and let her watch as it transcribed the messages.</p>
<p>Embedded below is what she said and what was transcribed&#8230;</p>
<p><object type="application/x-shockwave-flash" data="https://clients4.google.com/voice/embed/embedPlayer" width="100%" height="64"><param name="movie" value="https://clients4.google.com/voice/embed/embedPlayer" /><param name="wmode" value="transparent" /><param name="FlashVars" value="u=07560201795925896393&#038;k=AHwOX_CbkEWO9OEYuDS60zeU9tk80k8AIEUZ8V4TKESpQ7Cn0RMoKy0ZJY_P-tuGxq8TdqiYydFbRmdJnAX9T3hy9mlBWIXzyaBtNhYeEZG5GKGXXcROPoJJcuOtU_HZBGoENIHkrGlkFTohaTQy2XFrjIB6W_s7yelT2dlEjClPWfDX4o8n-8U&#038;baseurl=https://clients4.google.com/voice&#038;autoPlay=false&#038;cap=%20something%20love%20love%20love%20love%20right%20for%20us%20" /></object><br />
 <img src="http://wp.anoop.net/wp-content/uploads/2009/07/screen-capture-2.png" alt="peggys first voicemail" title="peggys first voicemail" width="876" height="88" class="alignnone size-full wp-image-107" /></p>
<p>What an amazing service! </p>
<p>It not only transcribed but also translated for me what she really meant. We both had a good laugh. Needless to say, she&#8217;s convinced that we&#8217;re meant to be together per GV.</p>
<p>I hope to see more uses of this feature in the future.</p>
]]></content:encoded>
			<wfw:commentRss>http://wp.anoop.net/2009/07/google-voice-voicemail-transcriptiontranslation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>testing identd from the command line (telnet)</title>
		<link>http://wp.anoop.net/2009/07/testing-identd-from-the-command-line-telnet/</link>
		<comments>http://wp.anoop.net/2009/07/testing-identd-from-the-command-line-telnet/#comments</comments>
		<pubDate>Wed, 22 Jul 2009 04:59:06 +0000</pubDate>
		<dc:creator>Anoop</dc:creator>
				<category><![CDATA[Meaningless]]></category>
		<category><![CDATA[Technobabble]]></category>
		<category><![CDATA[identd]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[sysadmin]]></category>
		<category><![CDATA[tcpdump]]></category>
		<category><![CDATA[telnet]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://wp.anoop.net/?p=90</guid>
		<description><![CDATA[You should know that I only recommend doing this on systems that you ABSOLUTELY trust. If you have any doubt what so ever, do NOT continue. I never thought i&#8217;d actually need this but i ended up actually providing it as a solution for securing database accounts. To get this working on CentOS 5, I [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p>You should know that I only recommend doing this on systems that you ABSOLUTELY trust. If you have any doubt what so ever, do NOT continue.
</p></blockquote>
<p>I never thought i&#8217;d actually need this but i ended up actually providing it as a solution for securing database accounts.</p>
<p>To get this working on CentOS 5, I had to do the following</p>
<p># yum install xinetd authd</p>
<p>authd is an xinetd service and authd is the RFC 1413 identd service</p>
<p>Out of the box, authd comes a little more secure than I expected. It&#8217;s not bad but it&#8217;s definitely a hindrance for other systems when they don&#8217;t know what to send.</p>
<p>/etc/xinetd.d/auth will come by default with<br />
<code><br />
server_args     = -t60 --xerror --os -E<br />
</code></p>
<p>This tells inetd to expect the &#8216;uname&#8217; instead of &#8216;UNIX&#8217; as the OS name. It&#8217;s great that it offers this option but I don&#8217;t know if all identd clients need to know what OS it is. You can leave it in if you like. Lastly, it tells identd to encrypt the username and then send it. I&#8217;m not sure how many identd clients can handle that.</p>
<p>I changed it to </p>
<p><code><br />
server_args     = -t60 --xerror<br />
</code></p>
<p>start or restart xinetd and you should see 113 listening.</p>
<p>I&#8217;m a lazy guy so I can&#8217;t be bothered to open more than one connection to a server. You can open two if you prefer.</p>
<p>I login and start tcpdump</p>
<p><code><br />
tcpdump -i lo -nn "port 113" &#038;<br />
telnet localhost 113<br />
</code></p>
<p>It should show you distinctly what port two ports are involved in the connection you just made. </p>
<p><em>IP 127.0.0.1.SOURCE_PORT_NUM > 127.0.0.1.113</em></p>
<p>Next type in &#8220;SOURCE_PORT_NUM,113&#8243; and hit Enter. Note that &#8220;SOURCE_PORT&#8221; here is a NUMBER not actually &#8220;SOURCE_PORT&#8221;</p>
<p>Amidst all the messy tcpdump output, you should see a line</p>
<p><em>SOURCE_PORT_NUM , 113 : USERID : UNIX :root</em></p>
<p>That shows you that identd is working properly. At least locally.</p>
<p>So if you ever find any of this useless knowledge helpful, let me know.</p>
<p>Unix/Linux admins are taught to hate identd because it&#8217;s pretty much the least secure protocol but I have to believe that it has a place in an environment that is completely trusted. You don&#8217;t have random users logging in or random accounts being created.</p>
<p>I think the overall advantage here is that you can use this to provide an additional layer of security across your trusted enterprise.</p>
]]></content:encoded>
			<wfw:commentRss>http://wp.anoop.net/2009/07/testing-identd-from-the-command-line-telnet/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>is your Linux Fu strong? Harness the power of &#8216;find&#8217;</title>
		<link>http://wp.anoop.net/2009/07/is-your-linux-fu-strong-harness-the-power-of-find/</link>
		<comments>http://wp.anoop.net/2009/07/is-your-linux-fu-strong-harness-the-power-of-find/#comments</comments>
		<pubDate>Fri, 10 Jul 2009 21:26:47 +0000</pubDate>
		<dc:creator>Anoop</dc:creator>
				<category><![CDATA[Technobabble]]></category>
		<category><![CDATA[administration]]></category>
		<category><![CDATA[awk]]></category>
		<category><![CDATA[files]]></category>
		<category><![CDATA[filesystem]]></category>
		<category><![CDATA[find]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[sed]]></category>
		<category><![CDATA[shell]]></category>

		<guid isPermaLink="false">http://wp.anoop.net/?p=43</guid>
		<description><![CDATA[I love find There is no other way to put it. It&#8217;s such a fantastic tool and once you get used to it, you almost never use the sub par &#8220;locate&#8221; utility to find files. Some of my favorite find switches and one liners are listed below. Explanations too. Find all directories in the current [...]]]></description>
			<content:encoded><![CDATA[<p>I love <a href="http://linux.about.com/od/commands/l/blcmdl1_find.htm">find</a></p>
<p>There is no other way to put it. It&#8217;s such a fantastic tool and once you get used to it, you almost never use the sub par &#8220;locate&#8221; utility to find files.</p>
<p>Some of my favorite find switches and one liners are listed below. Explanations too.</p>
<p>Find all directories in the current directory only without going any deeper that start with &#8220;20&#8243;. Note that I have included &#8216;-mindepth 1&#8242; and there is a reason for that. Try excluding it and you&#8217;ll see exactly what I mean.<br />
<code><br />
find ./ -maxdepth 1 -mindepth 1 -type d -name "20*"<br />
</code></p>
<p>Find all files named config.php in this directory and all sub directories. Print the name of the file and run &#8216;ls -al&#8217; on the file. run a grep command for &#8220;string1&#8243; (case insensitive) against the files. I find this command very useful in doing a single replacement across many files. It helps me determine what will change if I run a mass replacement. The &#8220;{}&#8221; at the end is the name of the file that is replaced in the command. Without that, you will get an error.<br />
<code><br />
find ./ -name "config.php" -ls -print -exec grep -i string1 {} \;<br />
</code></p>
<p>Now I can find those same files and then run a sed command that will replace all occurrences of string1 with string2. The &#8220;-i&#8221; in this case tells sed to make the change to the file in place without creating a new file. This way you have less to clean up but be careful because there is no backup. If you want to backup the file, use &#8220;-i&#8221; where  is the extension you want the backup file to have. E.g. -i.bak<br />
<code><br />
find ./ -name "config.php" -exec sed -i "s/string1/string2/g" {} \;</code></p>
<p>Another use of exec where you sub {} for the file name allows you to do cool things like back up many different files with the same condition. In this case, anything that is &#8220;config.*&#8221; will be &#8220;config.*.bak&#8221;.<br />
<code><br />
find ./-name "config.*" - exec cp {} {}.bak \;</code></p>
<p>Find any directories that have a no permissions for group and others. This is important if you want to find directories that don&#8217;t have permissions that are needed for users to enter a directory. After this, you can use -exec chmod 755 {} \; to change the permissions appropriately.<br />
<code><br />
find ./ -type d -perm 0700<br />
</code></p>
<p>Find any files that are owned by a particular user. You can also specify &#8220;-group&#8221; to find files by user and group names. I use this to find files owned by &#8220;root&#8221; in home directories and then chown them to the appropriate user.<br />
<code><br />
find ./ -user "username"<br />
</code></p>
<p>The -exec feature in find is perhaps the most valuable aspect of &#8220;find&#8221;. I use it several times a day in combination with <a href="http://www.gnu.org/software/sed/">sed</a> and <a href="http://www.gnu.org/manual/gawk/gawk.html">awk</a> to do all sorts of one liners that would normally need a script.</p>
<p>Don&#8217;t forget that you can do all sorts of really neat things with find, sed, awk if you use regular expressions.</p>
]]></content:encoded>
			<wfw:commentRss>http://wp.anoop.net/2009/07/is-your-linux-fu-strong-harness-the-power-of-find/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to get yesterday&#8217;s date using &#8216;date&#8217; in linux</title>
		<link>http://wp.anoop.net/2009/06/how-to-get-yesterdays-date-using-date-in-linux/</link>
		<comments>http://wp.anoop.net/2009/06/how-to-get-yesterdays-date-using-date-in-linux/#comments</comments>
		<pubDate>Mon, 15 Jun 2009 18:52:15 +0000</pubDate>
		<dc:creator>Anoop</dc:creator>
				<category><![CDATA[Technobabble]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://wp.anoop.net/?p=13</guid>
		<description><![CDATA[A while back, I was asked to come up with a logrotation script. This script would rotate all logs into a tarball and move it somewhere for archival purposes. The problem was that I couldn&#8217;t just rotate today&#8217;s logs because it would be incomplete. I had to intelligently find a way to rotate the previous [...]]]></description>
			<content:encoded><![CDATA[<p>A while back, I was asked to come up with a logrotation script.</p>
<p>This script would rotate all logs into a tarball and move it somewhere for archival purposes.</p>
<p>The problem was that I couldn&#8217;t just rotate today&#8217;s logs because it would be incomplete. I had to intelligently find a way to rotate the previous days logs (which would be complete) and then tar them up.</p>
<p>It turns out that you can do this with the &#8220;date&#8221; command in linux.</p>
<p style="padding-left: 30px;"><code><br />
YESTERDAY=$(date -d "yesterday" '+%Y-%m-%d')<br />
echo $YESTERDAY<br />
</code></p>
<p>This little snippet came in very handy and so I thought would share it.</p>
<p>The whole script is very small actually. Here it is. All you want to do is direct the output to a log file so you can review it later if need be. It&#8217;s chatty but you want chatty when you&#8217;re backing up and deleting log files.</p>
<p style="padding-left: 30px;"><code><br />
#!/bin/bash<br />
if [ $# -lt 3 ];  then<br />
echo "USAGE: backup_logs.sh ORIGINAL FILE-PREFIX- DESTINATION"<br />
exit<br />
fi<br />
# get command line variables<br />
FILE=$2<br />
ORIG=$1<br />
DEST=$3<br />
# get current time for log files.<br />
NOW=$(date)<br />
# get yesterdays date<br />
YESTERDAY=$(date -d "yesterday" '+%Y-%m-%d')<br />
# beginning entry in the log file<br />
echo "$NOW Backing up $FILE from $ORIG for $YESTERDAY to $DEST/$FILE-$YESTERDAY.tgz"<br />
echo "$NOW Command is /bin/tar -zcvf $DEST/$FILE$YESTERDAY.tgz $ORIG/$FILE$YESTERDAY*"<br />
/bin/tar -zcvf $DEST/$FILE$YESTERDAY.tgz $ORIG/$FILE$YESTERDAY*<br />
echo $NOW Done backing up logfiles to $DEST/$FILE-$YESTERDAY.tgz<br />
echo "$NOW removing files that were backed up."<br />
/bin/rm -vf $ORIG/$FILE$YESTERDAY*<br />
echo "$NOW done removing backuped up files."<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://wp.anoop.net/2009/06/how-to-get-yesterdays-date-using-date-in-linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
