<?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>Smart Pandian &#187; Add new tag</title> <atom:link href="http://smartpandian.com/tag/add-new-tag/feed/" rel="self" type="application/rss+xml" /><link>http://smartpandian.com</link> <description>as simple as that...</description> <lastBuildDate>Sun, 27 Nov 2011 05:17:18 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3</generator> <item><title>Unix Shell Arguments</title><link>http://smartpandian.com/unix-shell-arguments/</link> <comments>http://smartpandian.com/unix-shell-arguments/#comments</comments> <pubDate>Sun, 10 Jan 2010 17:58:51 +0000</pubDate> <dc:creator>Pandian</dc:creator> <category><![CDATA[Add new tag]]></category> <category><![CDATA[Scripts]]></category> <category><![CDATA[Shell]]></category> <category><![CDATA[Shell script]]></category> <category><![CDATA[Unix]]></category> <category><![CDATA[Unix Shell]]></category> <guid
isPermaLink="false">http://smartpandian.com/?p=377</guid> <description><![CDATA[A quick tutorial on Unix Shell Arguments.
No related posts.]]></description> <content:encoded><![CDATA[<p>For the past few weeks, I have been working on <a
class="zem_slink" title="Unix shell" rel="wikipedia" href="http://en.wikipedia.org/wiki/Unix_shell">Unix Shell</a>, to accomplish variety of tasks such as parsing files, transferring data, updating databases etc. Today is the day, i primarily worked on Arguments. Arguments are inputs to the program, and are also referred as parameters interchangeably.</p><p>Lets see how to use the arguments in the korn <a
class="zem_slink" title="Shell script" rel="wikipedia" href="http://en.wikipedia.org/wiki/Shell_script">shell script</a>, beginning with unix shell annotation for arguments.</p><blockquote><p><strong>$1, $2, $3 &#8230; $n</strong> First, Second, Third&#8230; and nth Argument<br
/> <strong>$#</strong> (hash)    Count of Arguments<br
/> <strong>$*</strong> (Asterisk)    Arguments concatenated by space<br
/> <strong>$@</strong> (at the rate)    Array of Arguments</p></blockquote><p>Here is an sample shell script &#8220;accessArguments.ksh&#8221;.</p><pre class="brush: bash; title: ; notranslate">
$ cat accessArguments.ksh
# accessArguments.ksh
echo Zeroth Argument: $0
echo First Argument: $1
echo Second Argument: $2
echo Total No. Of Arguments: $#
echo Arguments: $*
for var in $@
do
echo Argument $var
done
</pre><p>Now lets see the output of the above script,  with inputs as 10 and 15</p><pre class="brush: bash; title: ; notranslate">
$ accessArguments.ksh 10 15
Zeroth Argument : accessArguments.ksh
First Argument: 10
Second Argument: 15
Total No. Of Arguments: 2
Arguments: 10 15
Argument 10
Argument 15
$
</pre><p>Hope this example envisions you with the knowledge of using Arguments in Unix Shell.</p><div
class="zemanta-pixie" style="margin-top: 10px; height: 15px;"><a
class="zemanta-pixie-a" title="Reblog this post [with Zemanta]" href="http://reblog.zemanta.com/zemified/94c4adea-3b9f-44a9-b434-5d46c3a38302/"><img
class="zemanta-pixie-img" style="border: medium none; float: right;" src="http://img.zemanta.com/reblog_e.png?x-id=94c4adea-3b9f-44a9-b434-5d46c3a38302" alt="Reblog this post [with Zemanta]" /></a><span
class="zem-script more-related pretty-attribution"><script src="http://static.zemanta.com/readside/loader.js" type="text/javascript"></script></span></div><p>No related posts.</p>]]></content:encoded> <wfw:commentRss>http://smartpandian.com/unix-shell-arguments/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> </channel> </rss>
