<?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>Quick Tweaks &#187; bash</title>
	<atom:link href="http://www.quicktweaks.com/tag/bash/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.quicktweaks.com</link>
	<description>Quick Tweaks For Your System</description>
	<lastBuildDate>Fri, 27 Nov 2009 22:29:24 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Fun with Linux Commands-III &#8211; Being productive</title>
		<link>http://www.quicktweaks.com/2008/11/01/fun-with-linux-commands-iii-being-productive/</link>
		<comments>http://www.quicktweaks.com/2008/11/01/fun-with-linux-commands-iii-being-productive/#comments</comments>
		<pubDate>Sat, 01 Nov 2008 07:06:44 +0000</pubDate>
		<dc:creator>ashokgelal</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[TerminalFunFive]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[command]]></category>
		<category><![CDATA[script]]></category>

		<guid isPermaLink="false">http://www.quicktweaks.com/?p=252</guid>
		<description><![CDATA[Who says Linux commands are just for geek people? And who says it is just a fun toy? Linux is simple yet productive, the only limitation is your imagination.


Related posts:<ol><li><a href='http://www.quicktweaks.com/2009/11/26/10-linux-commands-for-fun/' rel='bookmark' title='Permanent Link: 10 Linux commands for fun'>10 Linux commands for fun</a> <small>Here are few Linux commands you can play with for...</small></li></ol>

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>Happy Linux commanding!</p>
<p>Who says Linux commands are just for geek people? And who says it is just a fun toy? Linux is simple yet productive, the only limitation is your imagination. Those who argue me with me for Linux being simple, here is a popular saying:</p>
<blockquote><p>*NIX is basically a simple operating system, but you have to be a genius to understand the simplicity</p></blockquote>
<p><span id="more-252"></span></p>
<p>In this post, we will talk about few commands and write a couple of scripts (don&#8217;t worry, it will be damn simple). Some guys might blame that these commands/ scripts have no use and might shout &#8220;why the hell do we need that.&#8221; Remember, these are just the tools. It&#8217;s upto you how well you use these tools for your tasks. Also remember, one who discovers the alternative uses of a tool is often called a Genious. Let&#8217;s get started:</p>
<p style="text-align: center;"><script type="text/javascript"><!--
google_ad_client = "pub-0816309066023726";
google_ad_slot = "7783831711";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</p>
<p>1. Make Linux speak that he loves himself.</p>
<p><code>espeak "I Love Linux"</code></p>
<p>Now you should be asking why the hell I need that? Well, what about you have a document, or a story and someone in your family is blind, or can&#8217;t see nicely. You don&#8217;t have enough time reading the document for him/ her. Ask him to sit in front of a computer and run this: espeak &lt; documentName</p>
<p>We have more to do with <em>espeak</em>, you can even output the file to a .wav file or a .ogg file so that you can record them in a CD and mail to someone you care!</p>
<p>Still not impressed? What about making it to read your email, or run it in the background so that it alerts you whenever a new mail arrives in your Inbox and then reads the sender&#8217;s name, and subject. Also, if you are little ambitious, you can even make it say the weather, if the weather changes drastically. I won&#8217;t discuss how to make it read your mails, or weather; I&#8217;m just talking about possibility. When I get some time, I&#8217;m thinking to write a script which reads my Gmails. Just keep coming back!</p>
<p>2. Making your own commands.</p>
<p>You have heard Linux is highly customizable. How about writing your own simple command. We will write a small script which allows you a convenient way to change the directories, actually to go back several levels up. Let&#8217;s suppose you are inside <em>/home/yourhome/a/b/c/d/e/f/g/h/i/j</em> directory. You want to change the directory (cd) to several levels up. You can easily do this with somthing like <em>cd ../../../../..</em> But what about something as similar as up 3 which will take you 3 levels up</p>
<p>Fireup your favorite text editor and type the following (don&#8217;t be intimated by thinking that you are programming something, I will explain this script line by line, don&#8217;w worry!):</p>
<p><code>#!/bin/bash<br />
LEVEL=$1<br />
for ((i = 1; i &lt;= LEVEL; i++))<br />
do<br />
CDIR=../$CDIR<br />
done<br />
cd $CDIR<br />
echo "You are in: "$PWD<br />
exec /bin/bash</code></p>
<p>Save the file as up and issue following two commands:</p>
<p><code>$ chmod 755 ./up</code></p>
<p>$ sudo cp up /usr/bin</p>
<p>Now, from your home directory try using this command:<br />
<code><br />
$ up 2</code></p>
<p>Where are you at? At root directory! See how easy it was? Let&#8217;s see how our little script chef made pizza for us:</p>
<p><code>#! /bin/bash</code> -&gt; you are using bash script</p>
<p><code>LEVEL=$1</code> -&gt; $1 is the first parameter passed to this script assigned to LEVEL</p>
<p><code>for ((i = 1; i &lt;= LEVEL; i++))</code> -&gt; for some times (upto LEVEL)&#8230;<br />
<code>do </code> -&gt; &#8230;we will go round&#8230;<br />
<code>CDIR=../$CDIR </code> -&gt; &#8230;creating our path and assigning it to CDIR and&#8230;<br />
<code>done</code> -&gt; &#8230;when we are done&#8230;<br />
<code>cd $CDIR</code> -&gt; &#8230;we will change our directory to the path we have created above and&#8230;<br />
<code>echo "You are in: "$PWD </code> -&gt; &#8230;we will let you know where you are and finally&#8230;<br />
<code>exec /bin/bash</code> -&gt; &#8230;we are done so let&#8217;s get a new shell</p>
<p>That&#8217;s was not to easy but wasn&#8217;t too hard either. It is not too hard to ease your repetitive tasks with a single file and increase your productivity.</p>
<p>Let&#8217;s make another little script&#8230;</p>
<p>3. What do you usually do changing a directory? List it contents right? How about this little script?</p>
<p><code>#!/bin/bash</code></p>
<p>cd $1</p>
<p>ls</p>
<p>exec /bin/bash</p>
<p>That&#8217;s it! Save it as <em>cdls</em> or something like that and then issue this command:<br />
<code>$ chmod 755 &amp; sudo cp cdls /usr/bin</code></p>
<p>For Ubuntu users, if you want a script that keeps track of all your &#8220;apt-get&#8221; activities by posting them to your Twitter account,<a title="tapt" href="http://www.quicktweaks.com/tapt/" target="_blank"> try this little handy script</a>.</p>
<p>4. One more thing about <em>cd</em>. Which is the fastest and easiest cd command that take you to your home directory? <strong><em>cd /home/yourhome </em></strong>? <em><strong>cd ~</strong></em> ? <em><strong>cd</strong></em> itself!</p>
<p><code>$ cd</code></p>
<p>It takes you to your home directory</p>
<p>5. Tired of typing clear to clear your screen? Press <code>ctrl + l</code></p>
<p>That&#8217;s it for today. Happy Halloween!</p>
<p style="text-align: center;"><script type="text/javascript"><!--
google_ad_client = "pub-0816309066023726";
google_ad_slot = "7783831711";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</p>


<p>Related posts:<ol><li><a href='http://www.quicktweaks.com/2009/11/26/10-linux-commands-for-fun/' rel='bookmark' title='Permanent Link: 10 Linux commands for fun'>10 Linux commands for fun</a> <small>Here are few Linux commands you can play with for...</small></li></ol></p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.quicktweaks.com/2008/11/01/fun-with-linux-commands-iii-being-productive/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic page generated in 0.616 seconds. -->
<!-- Cached page generated by WP-Super-Cache on 2009-11-28 05:17:51 -->
<!-- Compression = gzip -->