<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress.com" -->
<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/"
	>

<channel>
	<title>sed &amp;laquo; WordPress.com Tag Feed</title>
	<link>http://wordpress.com/tag/sed/</link>
	<description>Feed of posts on WordPress.com tagged "sed"</description>
	<pubDate>Sat, 11 Oct 2008 05:51:25 +0000</pubDate>

	<generator>http://wordpress.com/tags/</generator>
	<language>en</language>

<item>
<title><![CDATA[Willi will wählen  - Andrea (Ypsilanti)]]></title>
<link>http://fdog.wordpress.com/?p=6029</link>
<pubDate>Thu, 09 Oct 2008 13:39:37 +0000</pubDate>
<dc:creator>euckenserbe</dc:creator>
<guid>http://blog.fdog.org/2008/10/09/willi-wahlt-andrea-ypsilanti/</guid>
<description><![CDATA[und &#8220;Die Freunde Ulbrichts&#8221;(DFU) sitzen im hessischen Landtag. Für den Unterschied zwis]]></description>
<content:encoded><![CDATA[<p>und "Die Freunde Ulbrichts"(DFU) sitzen im hessischen Landtag. Für den Unterschied zwischen den rechts- und linksradikalen Parteien reicht ein Buchstabe. Die einen wollen uns ein F für ein V vormachen und umgekehrt (DVU). Willi van Oyen, heutiger Fraktionsvorsitzender der Linkspartei im hessischen Landtag ist nach einer langen Reise endlich an dem Ziel, das er schon als Funktionär der westdeutschen SED-Vorfeld-Organisation "Deutsche Friedensunion" verfolgte: DIe Macht am Rhein zu erlangen.<!--more--></p>
<p>Die <a href="http://www.faz.net/s/Rub61EAD5BEA1EE41CF8EC898B14B05D8D6/Doc~EE7B47E06D23B4560AE026702E27AE5D0~ATpl~Ecommon~Scontent.html" target="_blank">DFU </a>war ein trojanisches Pferd des DDR-Staatssozialismus, das alljährlich mit bis zu <a href="http://http://www.faz.net/s/Rub61EAD5BEA1EE41CF8EC898B14B05D8D6/Doc~EE7B47E06D23B4560AE026702E27AE5D0~ATpl~Ecommon~Scontent.html" target="_self">5 Millionen harten Westmark </a>alimentiert wurde. Das Gründungsmitglied von Westphalen war bereits seinerzeit als STASI-IM tätig.  Unverdächtig organisierte sie den <a href="http://de.wikipedia.org/wiki/Krefelder_Appell" target="_blank">Krefelder Apell</a> (Die hier verlinkte Wikipedia-Darstellung ist ein wenig tendenziös). So sollte die Umsetzung des<a href="http://de.wikipedia.org/wiki/NATO-Doppelbeschluss" target="_blank"> NATO-Doppelbeschlusses </a>verhindert werden soll. Westeuropa war damals in berechtigter Sorge, dass die Sowjet-Union die strategischen Interessen Europas und der USA auseinander dividieren, weil die frisch aufgerüsteten Mittelstreckenraketen SS-20 nur Europa bedrohten - Nordamerika aber mangels Reichweite nicht.</p>
<p>Das war im Strategiespiel "Kalter Krieg" logisch und richtig: So ließ man den Sowjets eine Frist, um die SS-20 wieder abzuziehen, andernfalls würde die NATO ihrerseits Mittelstreckenraketen (Pershing 2 und Cruise Missile) in Westeuropa stationieren. Ein begrenzter Schlag mit SS-20 hätte so qualifiziert beantwortet werden können, ohne  Raketen von amerikanischem Boden auf den Weg zu schicken.</p>
<p>Oyen und seine Genossen von der Deutschen Friedens Union organisierten mit DDR/SED-Geld den "<a href="http://de.wikipedia.org/wiki/Krefelder_Appell" target="_blank">Krefelder Apell". </a> Damit sollte die Stationierung der NATO-Mittelstreckenraketen verhindert werden. Über 4 Millionen Bundesbürger erlagen der DDR-Propaganda.</p>
<p>Wie ein Stasi-IM leugnet der Fraktionsführer der umbenannten SED seine Vergangenheit. Wer aber heute hier in den Kommentarzeilen behauptet, frisches Blut und neuer Name hätten aus den Altkommunisten einen demokratischen Haufen gemacht, sollte sich an den Kopf fassen. Frau Ypsilanti wird das nicht davon abhalten, sich von den Repräsentanten der Stasipartei zur hessischen Ministerpräsidentin wählen zu lassen.</p>
<p>Werden die hessichen Landtagsabgeordneten eigentlich auf eine mögliche STASI-Mitarbeit überprüft? Frau Birthler übernehmen Sie!</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Lektüretip: über das "Fleisch vom Fleische"...]]></title>
<link>http://anstalt.wordpress.com/2008/10/09/lekturetip-uber-das-fleisch-vom-fleische/</link>
<pubDate>Thu, 09 Oct 2008 12:04:09 +0000</pubDate>
<dc:creator>califax</dc:creator>
<guid>http://anstalt.wordpress.com/2008/10/09/lekturetip-uber-das-fleisch-vom-fleische/</guid>
<description><![CDATA[Linkspolitiker Willi van Ooyen: Honeckers Millionen für ein Trojanisches Pferd - Länder - Politik ]]></description>
<content:encoded><![CDATA[<p><a href="http://www.faz.net/s/Rub61EAD5BEA1EE41CF8EC898B14B05D8D6/Doc~EE7B47E06D23B4560AE026702E27AE5D0~ATpl~Ecommon~Scontent.html">Linkspolitiker Willi van Ooyen: Honeckers Millionen für ein Trojanisches Pferd - Länder - Politik - FAZ.NET</a>.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[It's Like...]]></title>
<link>http://asilee.wordpress.com/?p=27</link>
<pubDate>Tue, 07 Oct 2008 03:11:37 +0000</pubDate>
<dc:creator>kiqroqzgraphiqz</dc:creator>
<guid>http://asilee.it.wordpress.com/2008/10/07/its-like/</guid>
<description><![CDATA[People don&#8217;t give me a chance to let me explain myself. Lately though, I&#8217;ve been trying ]]></description>
<content:encoded><![CDATA[<p>People don't give me a chance to let me explain myself. Lately though, I've been trying to explain to myself that your boyfriend has a damn problem and he just like nudes and seeing other bitches on cams. Even when I'm in the next room it doesn't mean shit. I have this feeling that I'm not shit until I threaten to leave or break up. I'm not shit until I open my mouth. Its like I have to say something to him for him to realize that even though he says, he "don't do things to hurt me". It still does and he does hurt me cause he continues to do it. Anyway this whole blog isn't going to be about him and past problems that keep forcing themselves into the present cause the future threatens it so.</p>
<p>Oh before I change the subject this man goes crazy over his Y! Messenger list like he don't want me to find out something. Or he don't want me to reply back to shit but he can reply back to people under mine. If he have something to hide then it'll eventually come to light. It probably already has. He probably don't know that I realized what he's hiding. Half the broads on his list is either half naked or fully naked. Its gone be all to late before he actually wake up.</p>
<p>I'm trying this trust thing with him but my gut which is rarely wrong keeps telling me not to trust him; my heart is saying the same thing. Usually if it quacks like a duck...etc etc.</p>
<p>Anyway, my communications with people is very bad, I can't look folks in the eye half the time. I don't like talking but when its time to explain myself I have to go to my blog or something. I have to sit and think about what I want/have to say. Its very frustrating cause its like I can hear myself talk and before I open my mouth my brain tells me I sound stupid. Its reason behind all of that but thats not for strangers to read let alone people I know.</p>
<p>I've been mentally tired lately trying to know who this dude is that I go to sleep next to. But I'm not going to continue to figure him out. Half the time he acts like I caught him in something anyway. I'm not paranoid or nothing is just I know things. I have family and friends who've done it to me numerous times thinking I won't know the difference in their actions.</p>
<p>Its like I know when someone is gay or if I wouldn't like that person without me saying anything to them. Its not judging or anything is just I know in my heart. I'm good at reading people and sometimes I want to ask him; "what did you do or what you've gotten yourself into where you in here on my case acting all giddy and what not?"</p>
<p>I know I wouldn't get the answer to that.</p>
<p style="text-align:right;">-N-</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Hessen-SPD will mit Linken und Grünen verhandeln - Nachrichten Politik - WELT ONLINE]]></title>
<link>http://deutschezensur.wordpress.com/?p=476</link>
<pubDate>Sat, 04 Oct 2008 12:52:21 +0000</pubDate>
<dc:creator>igel</dc:creator>
<guid>http://deutschezensur.it.wordpress.com/2008/10/04/hessen-spd-will-mit-linken-und-grunen-verhandeln-nachrichten-politik-welt-online/</guid>
<description><![CDATA[Die hessische SPD nimmt Verhandlungen mit Grünen und Linkspartei mit dem Ziel der Regierungsüberna]]></description>
<content:encoded><![CDATA[<p>Die hessische SPD nimmt Verhandlungen mit Grünen und Linkspartei mit dem Ziel der Regierungsübernahme durch rot-grün unter Tolerierung der Linken auf. Neun Monate nach der Landtagswahl in Hessen gaben die Delegierten eines Landesparteitags ihrer vorsitzenden Andrea Ypsilanti grünes Licht für die Gespräche.</p>
<p><a href="http://www.welt.de/politik/article2529394/Hessen-SPD-will-mit-Linken-und-Gruenen-verhandeln.html">http://www.welt.de/politik/article2529394/Hessen-SPD-will-mit-Linken-und-Gruenen-verhandeln.html</a></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[SED Editor ]]></title>
<link>http://studylinuxblog.wordpress.com/?p=13</link>
<pubDate>Wed, 01 Oct 2008 06:54:54 +0000</pubDate>
<dc:creator>grevn</dc:creator>
<guid>http://studylinuxblog.it.wordpress.com/2008/10/01/sed-editor/</guid>
<description><![CDATA[-Syntax
sed [option] &#8216;command&#8217; files(s)
Eg: sed &#8217;s/old1/new1/&#8217;
s/old1/new1 i]]></description>
<content:encoded><![CDATA[<p>-Syntax<br />
sed [option] 'command' files(s)<br />
Eg: sed 's/old1/new1/'<br />
s/old1/new1 is a command<br />
sed -e 's/old1/new1/'<br />
e is an option<br />
sed 's/old1/new1/' *.*<br />
sed 's/old1/new1/' text1.txt text2.txt</p>
<p>SUBSTITUTION<br />
- Replace old value with new value<br />
sed 's/oldvalue/newvalue/'; 's/old2/new2/'<br />
sed -e 's/old1/new1/' -e /s/old2/new2/'<br />
s: mean substitution<br />
e: mean next argument<br />
- Change all tab to space<br />
sed 's/    / /g'<br />
- Replace with CONDITION<br />
sed '/condition/ s/old/new/'<br />
- Replace withi CONDITIONS in script file<br />
script file --- sedlist<br />
/con1/ s/old1/new1/<br />
/con2/ s/old2/new2/<br />
Call<br />
sed -f sedlist file1<br />
- Prohibiting display:<br />
Adding option -n<br />
sed -n ....<br />
- Want the result output to another file<br />
sed .... oldfile&#62;newfile</p>
<p>DELETEING</p>
<p>- Delete by condition text<br />
sed '/whattofind/ d'<br />
Eg: sed '/two/ d' sample_one</p>
<p>- Delete from rownum a to ronum b<br />
sed 'a,b d' sample_file<br />
Eg sed '1,5 d' sample_file</p>
<div id="middlecolumn">
<li> The up carat (^) signifies the beginning of a line, thus
<pre class="indent">sed '/^two/ d' sample_one</pre>
<p>would only delete the line if "two" were the first three   characters of the line.</li>
<li> The dollar sign ($) represents the end of the file, or the end   of a line, thus
<pre class="indent">sed '/two$/ d' sample_one</pre>
<p>would delete the line only if "two" were the last three characters   of the line.</p>
<p>The result of putting these two together:</p>
<pre class="indent">sed '/^$/ d' {filename}</pre>
<p>deletes all blank lines from a file. For example, the following   substitutes "1" for "2" as well as "1" for "3" and removes any   trailing lines in the file:</p>
<pre class="indent">$ sed '/two/ s/1/2/; /three/ s/1/3/; /^$/ d' sample_one
one     1
two     1
three   1
one     1
two     2
two     2
three   1
$</pre>
<p>A common use for this is to delete a header. The following command   will delete all lines in a file, from the first line through to the   first blank line:</p>
<pre class="indent">sed '1,/^$/ d' {filename}</pre>
</li>
</div>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Grado de Zaparación: fotoaventura]]></title>
<link>http://hectorfranotas.wordpress.com/?p=72</link>
<pubDate>Wed, 01 Oct 2008 03:47:10 +0000</pubDate>
<dc:creator>hectorfran</dc:creator>
<guid>http://hectorfranotas.it.wordpress.com/2008/09/30/zaparacion/</guid>
<description><![CDATA[
La isla de zapara: un magnifico pedazo de tierra flotante que recibe a quien se adentra a las aguas]]></description>
<content:encoded><![CDATA[<p><a href="http://hectorfranotas.files.wordpress.com/2008/09/zaparacion.jpg"><img src="http://hectorfranotas.wordpress.com/files/2008/09/zaparacion.jpg" alt="" title="zaparacion" width="410" height="201" class="alignnone size-full wp-image-73" /></a></p>
<p>La isla de zapara: un magnifico pedazo de tierra flotante que recibe a quien se adentra a las aguas del lago de Maracaibo. Un pequeño y alargado barquito se abre paso entre islotes y manglares para descargar a una docena de fotógrafos aficionados en este territorio isleño. Su misión, la de registrar fotográficamente las bellezas del lugar. Pero para seis de ellos, esta salida sabatina se transformó en la más aterrorizante y extrema aventura de sus vidas. Entre ellos, me encontraba (o me perdía) yo…</p>
<p><a href="http://hectorfranotas.wordpress.com/gradodezaparacion">Leer y ver historia completa...</a></p>
<p>Estas son algunas fotografías de la sesión <em>Grado de Zaparación </em>que esta en <a href="http://www.flickr.com/photos/hectorfran/sets/72157605585485451/">mi página en flickr. </a>Ahora si me bautizé con el photoshop lightroom para editar las imágenes. Amé el programita :)</p>
<p><a href="http://hectorfranotas.files.wordpress.com/2008/10/efectovespuccio.jpg"><img src="http://hectorfranotas.wordpress.com/files/2008/10/efectovespuccio.jpg" alt="" title="efectovespuccio" width="426" height="284" class="alignnone size-full wp-image-109" /></a><br />
Efecto Vespuccio</p>
<p><a href="http://hectorfranotas.files.wordpress.com/2008/10/aladerivaport.jpg"><img src="http://hectorfranotas.wordpress.com/files/2008/10/aladerivaport.jpg" alt="" title="aladerivaport" width="426" height="284" class="alignnone size-full wp-image-111" /></a><br />
A la deriva</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[CSU, CSU, CSU, ole, ole!]]></title>
<link>http://erdbeerenimwinter.wordpress.com/?p=114</link>
<pubDate>Mon, 29 Sep 2008 15:25:24 +0000</pubDate>
<dc:creator>Horst Paluschke</dc:creator>
<guid>http://erdbeerenimwinter.wordpress.com/2008/09/29/csu-csu-csu-ole-ole/</guid>
<description><![CDATA[Bayern hat gewählt – Was sind die Folgen?

München – Der letzte Sonntag förderte ein katastro]]></description>
<content:encoded><![CDATA[<p style="margin-bottom:0;" align="center"><span style="font-family:Arial,sans-serif;"><span style="font-size:large;"><strong>Bayern hat gewählt – Was sind die Folgen?</strong></span></span></p>
<p style="margin-bottom:0;">
<p style="margin-bottom:0;"><span style="font-family:Arial,sans-serif;"><span style="font-size:small;"><strong>München </strong>– Der letzte Sonntag förderte ein katastrophales Ergebnis für die CSU zu Tage. In nur 5 Jahren ein Verlust von mehr als 17%. Den Tränen nahe gestand der Huber Erwin: „Ja, ich bin schuld! Aber nicht alleine. Der Beckstein Günther und der Stoiber Edmund haben auch mitgemacht.“ Einzig Womanizer Horst Seehofer unbeschädigt aus der Wahl hervorgehen. Sein Umfragewert liegen weiterhin stabil bei 19,5% in der Zielgruppe. Als Konsequenz hat Huber (KPD) den Rücktritt von Seehofer als Bundesverbraucherminister und den Verzicht auf eine Reinigungskraft in der bayrischen Staatskanzlei bekannt gegeben.</span></span></p>
<p style="margin-bottom:0;"><a href="http://erdbeerenimwinter.wordpress.com/files/2008/09/abb11.jpg"><img class="alignleft size-full wp-image-125" title="abb1.jpg" src="http://erdbeerenimwinter.wordpress.com/files/2008/09/abb11.jpg" alt="" width="333" height="219" /></a><span style="font-family:Arial,sans-serif;"><span style="font-size:small;">Viele Bürger zeigen sich dennoch besorgt. Machte Huber in letzter Zeit einen besonders fanatischen Eindruck in In- und Ausland<a class="sdfootnoteanc" name="sdfootnote1anc" href="#sdfootnote1sym"><sup>5</sup></a> und gab Beckstein wie immer rechts-extremistische Äußerungen von sich, so konnte die berühmte 2-Maß-Rede dennoch nicht den Absturz der Partei in die Bedeutungslosigkeit von 43% verhindern. Dieser nibelungentreue Rest fragt sich jetzt natürlich, ob der Untergang droht, da die kommunistische Partei DIE LINKE 4,4% erringen konnte. Die Antwort ist einfach: Ja.</span></span></p>
<p style="margin-bottom:0;"><span style="font-family:Arial,sans-serif;"><span style="font-size:small;">Der Bund der Vertriebenen hat bereits reagiert und angekündigt, die Volksbewaffnung zu forcieren, um einen traditionellen<a class="sdfootnoteanc" name="sdfootnote2anc" href="#sdfootnote2sym"><sup>ß</sup></a> Ausgleich zu der kommunistischen Einflussnahme herzustellen.</span></span></p>
<p style="margin-bottom:0;"><span style="font-family:Arial,sans-serif;"><span style="font-size:small;">Doch die Betrachtung aller deutschen Alleinregierungsparteien bestätigt die schlimmsten </span></span><a href="http://erdbeerenimwinter.wordpress.com/files/2008/09/abb2.jpg"><img class="alignright size-full wp-image-126" title="abb2" src="http://erdbeerenimwinter.wordpress.com/files/2008/09/abb2.jpg" alt="" width="328" height="307" /></a><span style="font-family:Arial,sans-serif;"><span style="font-size:small;">Befürchtungen. Während die SED von Beginn an ein Spitzenergebnis präsentierte, positioniert sich die CSU im Vergleich zur anderen großen, von München und Bayern geprägten Partei (NAZIDAP) anfangs im Mittelfeld (Wikipedia/Kim 2005). Auch auf dem Höhepunkt ihrer Herrschaftszeit fällt die CSU durch ihre beständige Positionierung im Mittelfeld auf. Einzig ihre Durchschnittlichen Alleinregierungsjahre liegen an der Spitze. Doch dies konnte ihren Absturz nicht verhindern. Schon die SED bewies, dass Spitzenergebnisse über Jahre hinweg nicht vor einem schnellen Ende schützen können. Nur ihre Mittelmäßigkeit könnte die CSU jetzt noch vor dem totalen Ende retten. Oder der Rückzug in den Widerstand. Das dürfte der Partei allerdings schwer fallen, schnürte der damalige Innenminister und jetziger Promilleprinz Bayerns, Becksteingünther, doch den Sicherheitscockring der Bayern besonders fest. Auch ist die Partei eher unerfahren, was Untergrundaktivitäten gegen den Staat angeht. Ein Zusammengehen mit der ETA oder der IRA währe demnach sehr wahrscheinlich, sollte die Partei diesen Weg einschlagen wollen.</span></span></p>
<p style="margin-bottom:0;"><span style="font-family:Arial,sans-serif;"><span style="font-size:small;">Bleibt die Frage, wohin trieb es die Millionen Ex-CSU Wähler trieb. Eine Theorie der CIA und des Mossad belegen mit Daten des BGS, dass sich in den letzten Wochen ein Strom Bayern nach Weißrussland abgesetzt hat. Indizien hierfür bietet auch das Wahlergebnis vom gleichen Tag wie die Bayernwahl. So gewann die Partei von Staatschef Lukaschenko jeden Sitz im Parlament. Insider<a class="sdfootnoteanc" name="sdfootnote3anc" href="#sdfootnote3sym"><sup>13</sup></a> aus der Wahlbeobachtungskommission der OSZE ließen durchblicken, dass dies wohl nur durch die Stimmen der zugewanderten alleinregierungsliebenden Bayern möglich wurde.</span></span></p>
<p style="margin-bottom:0;"><span style="font-family:Arial,sans-serif;"><span style="font-size:small;">Der Staatsschutz ermittelt.</span></span></p>
<p style="margin-bottom:0;">
<p style="margin-bottom:0;"><span style="font-family:Arial,sans-serif;"><span style="font-size:medium;">Literaturangabe</span></span></p>
<p style="margin-bottom:0;">
<p style="margin-left:1cm;text-indent:-1cm;margin-bottom:0;"><span style="font-family:Arial,sans-serif;"><span style="font-size:x-small;"><em>Spears, Britney/Hawking, Stephen </em>(2008): Deutschland sucht den krassesten Kommunistenhasser. Das Buch. Berlin. Axel Springer.</span></span></p>
<p style="margin-bottom:0;">
<p style="margin-left:1cm;text-indent:-1cm;margin-bottom:0;"><span style="font-family:Arial,sans-serif;"><span style="font-size:x-small;"><em>von der Vogelweide, Walther</em><span style="font-style:normal;"> (1223): Ottenton. Bozen. Handschriftlich.</span></span></span></p>
<p style="margin-left:1cm;text-indent:-1cm;margin-bottom:0;font-style:normal;">
<p style="margin-left:1cm;text-indent:-1cm;margin-bottom:0;"><span style="font-family:Arial,sans-serif;"><span style="font-size:x-small;"><em>Wikipedia, Seirmour-Klaus/Kim, Young Ill </em>(2005): Bavaria's CSU. Heir to Hitler? Demin. KNAX-Hefte Verlag.</span></span></p>
<div id="sdfootnote1">
<p class="sdfootnote"><span style="font-family:Arial,sans-serif;"><span style="font-size:x-small;"><a class="sdfootnotesym" name="sdfootnote1sym" href="#sdfootnote1anc">5</a>So 	zum Beispiel bei seinem Überraschungsbesuch in China im Sommer 	2008. Huber hatte sich in einem Transportflugzeug mit 	Werbegeschenken der deutschen Wirtschaft versteckt und geschickt an 	den Sicherheitskontrollen vorbei geschmuggelt. Während der 	Eröffnungsrede schlich Huber sich als Kanzlerin Merkel 	verkleidet an den Ministerpräsidenten Chinas heran und versucht 	ihn zu erwürgen. Einzig der beherzte Einsatz des 	VW-Vorstandsvorsitzenden Martin Winterkorn konnte den 	Ministerpräsidenten und die deutsch-chinesischen Beziehungen 	retten. Huber zog sich im Anschluss zum Wundenlecken nach Wildbad 	Kreuth zurück (vgl. Spears/Hawking 2008).</span></span></p>
</div>
<div id="sdfootnote2">
<p class="sdfootnote"><span style="font-family:Arial,sans-serif;"><span style="font-size:x-small;"><a class="sdfootnotesym" name="sdfootnote2sym" href="#sdfootnote2anc">ß</a>Bereits 	Anfang der 1920er Jahre wurde alles Links vom Zentrum mit Kugeln der 	zahlreichen nationalen Freikorps durchsiebt. Diese Tradition lebt in 	den zahlreichen Schützenvereinen Bayerns fort, wo immer noch 	auf die Kommunistensau im Maßstab 1:10 geschossen wird.</span></span></p>
</div>
<div id="sdfootnote3">
<p class="sdfootnote"><span style="font-family:Arial,sans-serif;"><span style="font-size:x-small;"><a class="sdfootnotesym" name="sdfootnote3sym" href="#sdfootnote3anc">13</a>Rudolph 	Stendlmayr, Am Kupfergraben 89, 78554 Drusingen</span></span></p>
</div>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Berlin oder Bayern, SED oder CSU kein Palast hält ewig ]]></title>
<link>http://spreeathen.wordpress.com/?p=25</link>
<pubDate>Mon, 29 Sep 2008 07:46:11 +0000</pubDate>
<dc:creator>spreeathen</dc:creator>
<guid>http://spreeathen.it.wordpress.com/2008/09/29/berlin-oder-bayern-sed-oder-csu-kein-palast-halt-ewig/</guid>
<description><![CDATA[
]]></description>
<content:encoded><![CDATA[<p><a href="http://spreeathen.files.wordpress.com/2008/09/cimg7350.jpg"><img class="aligncenter size-large wp-image-26" title="cimg7350" src="http://spreeathen.wordpress.com/files/2008/09/cimg7350.jpg?w=450" alt="" width="450" height="337" /></a></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Using sed !]]></title>
<link>http://vijaydev.wordpress.com/?p=271</link>
<pubDate>Thu, 25 Sep 2008 16:34:03 +0000</pubDate>
<dc:creator>Vijay Dev</dc:creator>
<guid>http://vijaydev.it.wordpress.com/2008/09/25/using-sed/</guid>
<description><![CDATA[Learned a bit of sed today when there was a need to search and replace a given text in some n files.]]></description>
<content:encoded><![CDATA[<p>Learned a bit of sed today when there was a need to search and replace a given text in some n files.</p>
<p><code>$ sed -e 's/TEXT_TO_FIND/TEXT_TO_REPLACE/g' SRCFILENAME &#62; DESTFILENAME</code></p>
<p>Need to use -i instead of -e if we want to do the replace operation "in place". There is also an option to backup the source file when doing this !</p>
<p>To do the same for a given set of html files, I used a combination of find and xargs and also the -i switch for the sed command:</p>
<p><code>$ find -iname '*.html' -print0 &#124; xargs -0 </code><code>sed -i 's/TEXT_TO_FIND/TEXT_TO_REPLACE/g' </code></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Landtagswahl in Bayern: Linke kann über den Erfolg der CSU entscheiden - Nachrichten Politik - WELT ONLINE]]></title>
<link>http://deutschezensur.wordpress.com/?p=375</link>
<pubDate>Thu, 25 Sep 2008 13:52:20 +0000</pubDate>
<dc:creator>igel</dc:creator>
<guid>http://deutschezensur.it.wordpress.com/2008/09/25/landtagswahl-in-bayern-linke-kann-uber-den-erfolg-der-csu-entscheiden-nachrichten-politik-welt-online/</guid>
<description><![CDATA[Im konservativen Bayern sind die Vorraussetzungen [sic] für die Linke schlecht. Der bayerische Verf]]></description>
<content:encoded><![CDATA[<p>Im konservativen Bayern sind die Vorraussetzungen [sic] für die Linke schlecht. Der bayerische Verfassungsschutz bezeichnet die Partei als extremistisch. Doch die nachlassende Bindungskraft der CSU ist eine Chance für die Linken. Ihr Erfolg oder Misserfolg kann über den Erfolg oder Misserfolg der CSU entscheiden.</p>
<p><a href="http://www.welt.de/politik/article2481703/Linke-kann-ueber-den-Erfolg-der-CSU-entscheiden.html">http://www.welt.de/politik/article2481703/Linke-kann-ueber-den-Erfolg-der-CSU-entscheiden.html</a></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Poema: 'Sed']]></title>
<link>http://geeknazgul.wordpress.com/?p=699</link>
<pubDate>Mon, 22 Sep 2008 22:28:18 +0000</pubDate>
<dc:creator>Jaguar</dc:creator>
<guid>http://geeknazgul.it.wordpress.com/2008/09/22/poema/</guid>
<description><![CDATA[Bueno, como verán raza me encanta la poesía, y la neta por lo que leerán es un poema algo melanco]]></description>
<content:encoded><![CDATA[<p>Bueno, como verán raza me encanta la poesía, y la neta por lo que leerán es un poema algo melancolico<a href="http://geeknazgul.files.wordpress.com/2008/09/onion-5.gif"><img class="alignnone size-full wp-image-700" title="onion-5" src="http://geeknazgul.wordpress.com/files/2008/09/onion-5.gif" alt="" width="50" height="50" /></a></p>
<blockquote><p><em><strong>Cada día que pasa sin lograr que me quiera<br />
es un día perdido...<br />
¡Oh Señor, no permitas por piedad que me muera<br />
sin que me haya querido!<br />
Porque entonces mi espíritu, con su sed no saciada<br />
con su anhelo voraz,<br />
errará dando tumbos por la noche estrellada,<br />
como pájaro loco, sin alivio ni paz...</strong></em></p></blockquote>
<p>By Amado Nervo</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[UNIX / Shell Programming Basic – Beginner Questions Answers]]></title>
<link>http://knoworacle.wordpress.com/?p=411</link>
<pubDate>Mon, 22 Sep 2008 12:29:08 +0000</pubDate>
<dc:creator>shivmohan purohit</dc:creator>
<guid>http://knoworacle.it.wordpress.com/2008/09/22/unix-shell-programming-basic-%e2%80%93-beginner-questions-answers/</guid>
<description><![CDATA[
 
 
What is $*?
Its mainly used for showing up all params. This show all parameter values passed]]></description>
<content:encoded><![CDATA[<p class="MsoNormal" style="text-align:justify;margin:0;"><strong><span style="font-size:10.5pt;color:#333399;"></span></strong></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-size:10pt;color:#000000;"><span style="font-family:Times New Roman;"> <img src="http://uw714doc.sco.com/en/SHL_using/graphics/unixView.gif" alt="" width="428" height="369" /></span></span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-size:10pt;color:#000000;"><span style="font-family:Times New Roman;"> </span></span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">What is $*?</span></span></p>
<p class="MsoNormal" style="margin:0;"><span class="tdvamseel"><span style="font-size:10pt;"><span style="font-family:Times New Roman;">Its mainly used for showing up all params. This show all parameter values passed in shell script</span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span class="tdvamseel"><span style="font-size:10pt;"><span style="font-family:Times New Roman;"> </span></span></span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">What does $# stand for?</span></span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span class="tdvamseel"><span style="font-size:10pt;"><span style="font-family:Times New Roman;"># will return the number of parameters that are passed as the command-line arguments.</span></span></span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;"> </span></span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">What does $? Return?</span></span></p>
<p class="MsoNormal" style="margin:0;"><span class="tdvamseel"><span style="font-size:10pt;"><span style="font-family:Times New Roman;">$? will return exit status of command .0 if command gets successfully executed ,non-zero if command failed.</span></span></span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;"> </span></span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">What are Different types of shells?</span></span></p>
<p class="MsoNormal" style="margin:0;"><span class="tdvamseel"><span style="font-size:10pt;"><span style="font-family:Times New Roman;">sh : the oldest shell </span></span></span><span style="font-size:10pt;"><br />
<span style="font-family:Times New Roman;"><span class="tdvamseel"><span>csh : C shell </span></span><br />
<span class="tdvamseel"><span>ksh : Korn Shell </span></span><br />
<span class="tdvamseel"><span>bash : bourne again shell</span></span></span></span><span class="tdvamseel"><span style="font-size:10pt;font-family:&#34;"> </span></span></p>
<div class="MsoNormal" style="margin:0;"></div>
<p><span style="font-size:10pt;font-family:&#34;"> </p>
<p></span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">How do you read arguments in a </span><a href="http://www.geekinterview.com/question_details/12852" target="_new"><span style="color:#008000;text-decoration:none;"><span style="font-family:Times New Roman;">shell</span></span></a><span style="font-family:Times New Roman;"> program - $1, $2?</span></span></p>
<p class="MsoNormal" style="margin:0;"><span class="tdvamseel"><span style="font-size:10pt;"><a href="http://www.geekinterview.com/question_details/12852" target="_new"><span style="color:windowtext;text-decoration:none;"><span style="font-family:Times New Roman;">Shell script</span></span></a><span style="font-family:Times New Roman;"> accepts parameters in following format... <br />
$1 would be the first command line argument, $2 the second, and so on <br />
$0 is the name of the script or function</span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span class="tdvamseel"><span style="font-size:10pt;"><span style="font-family:Times New Roman;">If your script has more than 9 params then accept in following way... <br />
${12} : 12th param <br />
${18} : 18th param</span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span class="tdvamseel"><span style="font-size:10pt;"><span style="font-family:Times New Roman;"> </span></span></span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">What are the different kinds of loops available in </span><a href="http://www.geekinterview.com/question_details/12853" target="_new"><span style="color:#008000;text-decoration:none;"><span style="font-family:Times New Roman;">shell script</span></span></a><span style="font-family:Times New Roman;">?</span></span></p>
<p class="MsoNormal" style="margin:0;"><span class="tdvamseel"><span style="font-size:10pt;font-family:&#34;">for, if, while, case</span></span><span class="tdvamseel"></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#000000;"><span style="font-family:Times New Roman;"> </span></span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">What is the difference between a </span><a href="http://www.geekinterview.com/question_details/12857" target="_new"><span style="color:#008000;text-decoration:none;"><span style="font-family:Times New Roman;">shell</span></span></a><span style="font-family:Times New Roman;"> variable that is exported and the one that is not exported?</span></span></p>
<p class="MsoNormal" style="margin:0;"><span class="tdvamseel"><span style="font-size:10pt;"><span style="font-family:Times New Roman;">The Shell variable which is exported would available to all the programs outside the Shell also. And the shell variable which is not exported, would available for that shell or for the shell program only, in which the variable is declared.</span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span class="tdvamseel"><span style="font-size:10pt;"><span style="font-family:Times New Roman;"> </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span class="tdvamseel"><span style="font-size:10pt;"><span style="font-family:Times New Roman;">Export LANG=C <br />
will make the variable LANG the </span><a href="http://www.geekinterview.com/question_details/12857" target="_new"><span style="color:windowtext;text-decoration:none;"><span style="font-family:Times New Roman;">global variable</span></span></a><span style="font-family:Times New Roman;">, put it into the global environment. All other processes can use it. <br />
 <br />
LANG=C <br />
will change the value only in the current script. </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span class="tdvamseel"><span style="font-size:10pt;"><span style="font-family:Times New Roman;"> </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span class="tdvamseel"><span style="font-size:10pt;"><span style="font-family:Times New Roman;"> </span></span></span><span class="tdvamseel"><span style="font-size:10pt;"><span style="font-family:Times New Roman;"> </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">If you have a string "one two three", which </span><a href="http://www.geekinterview.com/question_details/12858" target="_new"><span style="color:#008000;text-decoration:none;"><span style="font-family:Times New Roman;">shell</span></span></a><span style="font-family:Times New Roman;"> command would you use to extract the strings?</span></span></p>
<p class="MsoNormal" style="margin:0;"><span class="tdvamseel"><span style="font-size:10pt;font-family:&#34;">echo $string &#124; cut -d" " -f1 </span></span><span style="font-size:10pt;font-family:&#34;"><br />
<span class="tdvamseel"><span>echo $string &#124; cut -d" " -f2 </span></span><br />
<span class="tdvamseel"><span>echo $string &#124; cut -d" " -f3 </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span class="tdvamseel"><span style="font-size:10pt;font-family:&#34;"> </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">How will you list only the empty lines in a file (using grep)?</span></span></p>
<p class="MsoNormal" style="margin:0;"><span class="tdvamseel"><span style="font-size:10pt;"><span style="font-family:Times New Roman;">grep "^$" filename.txt</span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span class="tdvamseel"><span style="font-size:10pt;"><span style="font-family:Times New Roman;"> </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">How would you get the character positions 10-20 from a text file?</span></span></p>
<p class="MsoNormal" style="margin:0;"><span class="tdvamseel"><span style="font-size:10pt;"><span style="font-family:Times New Roman;">cat filename.txt &#124; cut -c 10-20</span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span class="tdvamseel"><span style="font-size:10pt;"><span style="font-family:Times New Roman;">or</span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span class="tdvamseel"><span style="font-size:10pt;"><span style="font-family:Times New Roman;">cut -c10-20 &#60;filename.txt&#62;</span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;"> </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">How would you replace the n character in a file with some xyz?</span></span></p>
<p class="MsoNormal" style="margin:0;"><span class="tdvamseel"><span style="font-size:10pt;"><span style="font-family:Times New Roman;">sed 's/n/xyz/g' filename &#62; new_filename</span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span class="tdvamseel"><span style="font-size:10pt;"><span style="font-family:Times New Roman;"> </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span class="tdvamseel"><span style="font-size:10pt;"><span style="font-family:Times New Roman;">We can replace n characters by using the following command:</span></span></span><span style="font-size:10pt;"><br />
<span style="font-family:Times New Roman;"><span class="tdvamseel"><span>1,$s/./xyz/g</span></span><br />
</span><span class="tdvamseel"><span><span style="font-family:Times New Roman;">where 1 shows that the search string will start </span><a href="http://www.geekinterview.com/question_details/12864" target="_new"><span style="color:windowtext;text-decoration:none;"><span style="font-family:Times New Roman;">searching</span></span></a><span style="font-family:Times New Roman;"> patterns from first line of the file.<br />
           '.' for any character.</span></span></span><br />
<span class="tdvamseel"><span><span style="font-family:Times New Roman;">            g for global replacemet.</span></span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span class="tdvamseel"><span style="font-size:10pt;"><span style="font-family:Times New Roman;"> </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span class="tdvamseel"><span style="font-size:10pt;"><span style="font-family:Times New Roman;"> </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">What is the difference between a 'thread' and a 'process'?</span></span></p>
<p class="MsoNormal" style="margin:0;"><span class="tdvamseel"><span style="font-size:10pt;"><span style="font-family:Times New Roman;">A process is a collection of </span><a href="http://www.geekinterview.com/question_details/16712" target="_new"><span style="color:windowtext;text-decoration:none;"><span style="font-family:Times New Roman;">virtual memory</span></span></a><span style="font-family:Times New Roman;"> space, code, data, and system resources. A thread is code that is to be serially executed within a process. A </span><a href="http://www.geekinterview.com/question_details/16712" target="_new"><span style="color:windowtext;text-decoration:none;"><span style="font-family:Times New Roman;">processor</span></span></a><span style="font-family:Times New Roman;"> executes threads, not processes, so each </span><a href="http://www.geekinterview.com/question_details/16712" target="_new"><span style="color:windowtext;text-decoration:none;"><span style="font-family:Times New Roman;">application</span></span></a><span style="font-family:Times New Roman;"> has at least one process, and a process always has at least one thread of execution, known as the primary thread. A process can have multiple threads in addition to the primary thread</span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span class="tdvamseel"><span style="font-size:10pt;"><span style="font-family:Times New Roman;">Thread – is stream of executable code within process. They are light weight process. All thread with in a process  share process instruction,code &#38; data segment,</span><a href="http://www.geekinterview.com/question_details/16712" target="_new"><span style="color:windowtext;text-decoration:none;"><span style="font-family:Times New Roman;">open file</span></span></a><span style="font-family:Times New Roman;"> descriptor,signal handler,userID and GroupID. Thread has its own set of register including program counter,stack pointer </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;"> </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">What is this line in the </span><a href="http://www.geekinterview.com/question_details/30345" target="_new"><span style="color:#008000;text-decoration:none;"><span style="font-family:Times New Roman;">shell script</span></span></a><span style="font-family:Times New Roman;"> do ?#!/bin/ksh?</span></span></p>
<p class="MsoNormal" style="margin:0;"><span class="tdvamseel"><span style="font-size:10pt;"><span style="font-family:Times New Roman;">To invoke the shell indirectly this line is added as the first line in the file.This particular line invokes korn shell</span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span class="tdvamseel"><span style="font-size:10pt;font-family:&#34;"> </span></span></p>
<p class="MsoNormal" style="margin:0;"><span class="tdvamseel"><span style="font-size:10pt;font-family:&#34;"> </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">What is use of "cut" command? Give some examples. </span></span></p>
<p class="MsoNormal" style="margin:0;"><span class="tdvamseel"><span style="font-size:10pt;"><span style="font-family:Times New Roman;">Cut - Utility used to cut/Strip out the required data/text from the source.</span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span class="tdvamseel"><span style="font-size:10pt;"><span style="font-family:Times New Roman;">Cut can be used in three modes,</span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span class="tdvamseel"><span style="font-size:10pt;"><span style="font-family:Times New Roman;">  Stripping by Character</span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span class="tdvamseel"><span style="font-size:10pt;"><span style="font-family:Times New Roman;">     cut -c 1-3</span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span class="tdvamseel"><span style="font-size:10pt;"><span style="font-family:Times New Roman;">  Striping by Byte length</span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span class="tdvamseel"><span style="font-size:10pt;"><span style="font-family:Times New Roman;">     cut -b -1-72</span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span class="tdvamseel"><span style="font-size:10pt;"><span style="font-family:Times New Roman;">Stripping by delimiter and fields.</span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span class="tdvamseel"><span style="font-size:10pt;"><span style="font-family:Times New Roman;">     cut -d "&#124;" -f1</span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span class="tdvamseel"><span style="font-size:10pt;"><span style="font-family:Times New Roman;">Where   </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span class="tdvamseel"><span style="font-size:10pt;"><span style="font-family:Times New Roman;">-d "&#124;" -&#62; Delimiter used in input text to separate columns</span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span class="tdvamseel"><span style="font-size:10pt;"><span style="font-family:Times New Roman;">-f1 -&#62; Field/Column number  </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span class="tdvamseel"><span style="font-size:10pt;"><span style="font-family:Times New Roman;">While processing huge input files, Cut's performance is far better than awk</span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;"> </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;"> <img src="http://ecx.images-amazon.com/images/I/412uhpGEJdL._SL500_AA240_.jpg" alt="" /></span></span><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;"> </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">thanks - shivmohan purohit </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;"> </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;"> </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;"> </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;"> </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;"> </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;"> </span></span></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Basic Unix  Vi editor command ]]></title>
<link>http://knoworacle.wordpress.com/?p=394</link>
<pubDate>Tue, 16 Sep 2008 11:18:23 +0000</pubDate>
<dc:creator>shivmohan purohit</dc:creator>
<guid>http://knoworacle.it.wordpress.com/2008/09/16/basic-unix-vi-editor-command/</guid>
<description><![CDATA[ 
Unix  Vi editor command keys:
 




ZZ     
Q      
&lt;ESC&gt;  
:&lt;cmd&gt; 
:!]]></description>
<content:encoded><![CDATA[<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;"><span style="font-family:Times New Roman;"> </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Times New Roman;"><strong><span style="font-size:10.5pt;">Unix<span>  </span></span></strong><strong><span style="font-size:10.5pt;color:#333399;">Vi editor command keys:</span></strong><strong></strong></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;"><span style="font-family:Times New Roman;"> </span></span></p>
<table style="border-collapse:collapse;" border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td style="width:59.4pt;background-color:transparent;border:windowtext 0.5pt solid;padding:0 5.4pt;" width="79" valign="top">
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">ZZ<span>     </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">Q<span>      </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">&#60;ESC&#62;<span>  </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">:&#60;cmd&#62; </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">:!&#60;cmd&#62;</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">^g<span>     </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">^f<span>     </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">^b<span>     </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">^d<span>     </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">^u<span>     </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">&#60;x&#62;G<span>   </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">/&#60;x&#62;<span>   </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">?&#60;x&#62;<span>   </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">n<span>      </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">N<span>      </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">]]<span>     </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">[[<span>     </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">%<span>      </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">^l<span>     </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">^r<span>     </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">z&#60;CR&#62;<span>  </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">z-<span>     </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">^e<span>   </span><span>  </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">^y<span>     </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">“<span>      </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">H<span>      </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">L<span>      </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">M<span>      </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">+<span>      </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">hjkl<span>   </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;"><span>       </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">0<span>      </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">$<span>      </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">f&#60;x&#62;<span>   </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">F&#60;x&#62;<span>   </span></span></span></p>
</td>
<td style="border-right:windowtext 0.5pt solid;border-top:windowtext 0.5pt solid;border-left:#ece9d8;width:2in;border-bottom:windowtext 0.5pt solid;background-color:transparent;padding:0 5.4pt;" width="192" valign="top">
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">Exit, saving changes<span>      </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">Enter ex mode<span>             </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">End of insert<span>             </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">Execute ex command<span>        </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">Shell command<span>             </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">Show filename/size<span>    </span><span>    </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">Forward one screen<span>        </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">Back one screen<span>           </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">Forward half screen<span>       </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">Backward half screen<span>      </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">Go to line &#60;x&#62;<span>            </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">Search forward for &#60;x&#62;<span>    </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">Search backward for &#60;x&#62;<span>   </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">Repeat last search<span>        </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">Reverse last search<span>       </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">Next section/function<span>     </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">Previous section/function </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">Find matching () { or }<span>   </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">Redraw screen<span>             </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">Refresh screen<span>            </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">Current line at top<span>       </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">Current line at bottom<span>    </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">Scroll down one line<span>      </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">Scroll up one line<span>        </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">revious context<span>      </span><span>     </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">Home window line<span>          </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">Last window line<span>          </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">Middle window line<span>        </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">Next line<span>                 </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">Cursor movement:<span>          </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">left/down/up/right<span>        </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">Beginning of line<span>         </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">End of line<span>               </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">Find &#60;x&#62; forward<span>          </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">Find &#60;x&#62; backward<span>         </span></span></span></p>
</td>
</tr>
</tbody>
</table>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;" lang="EN"><span style="font-family:Times New Roman;"><span>  </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;"><span style="font-family:Times New Roman;"> </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;"><span style="font-family:Times New Roman;"> </span></span></p>
<table style="border-collapse:collapse;" border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td style="width:59.4pt;background-color:transparent;border:windowtext 0.5pt solid;padding:0 5.4pt;" width="79" valign="top">
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">t&#60;x&#62; </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">T&#60;x&#62; </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">&#60;x&#62;&#124; </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">w,W<span>  </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">b,B<span>  </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">e,E<span>  </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">^h<span>   </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">^w<span>   </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">^?<span>   </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">~<span>    </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">a<span>    </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">i,I<span>  </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">A<span>    </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">o<span>    </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">O<span>    </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">r<span>    </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">R<span>    </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">d<span>    </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">dd<span>   </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">c<span>    </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">y<span>    </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">C<span>    </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">D<span>    </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">s<span>    </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">S<span>    </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">J<span>    </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">x<span>    </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">X<span>    </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">Y<span>    </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">p<span>    </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">P<span>    </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">&#60;&#60;<span>   </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">&#62;&#62;<span>   </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">u<span>    </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">U<span>    </span></span></span></p>
</td>
<td style="border-right:windowtext 0.5pt solid;border-top:windowtext 0.5pt solid;border-left:#ece9d8;width:2in;border-bottom:windowtext 0.5pt solid;background-color:transparent;padding:0 5.4pt;" width="192" valign="top">
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">Up to &#60;x&#62; forward</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">Back up to &#60;x&#62;</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">Go to column &#60;x&#62;</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">Forward one word</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">Back one word</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">End of word</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">Erase last character</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">Erase last word</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">Interrupt</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">Toggle character case</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">Append after</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">Insert before</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">Append at end of line</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">Open line below</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">Open line above</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">Replace character</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">Replace characters</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">Delete</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">Delete line</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">Change</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">Yank lines to buffer</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">Change rest of line</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">Delete rest of line</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">Substitute character</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">Substitute lines</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">Join lines</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">Delete after</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">Delete before</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">Yank current line</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">Put back lines</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">Put before</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">Shift line left</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">Shift line right</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">Undo last change</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">Restore current line</span></span></p>
</td>
</tr>
</tbody>
</table>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;"><span style="font-family:Times New Roman;"> </span></span></p>
<p class="MsoNormal" style="margin:0;"><strong><span style="font-size:10pt;"><span style="font-family:Times New Roman;">File Options: </span></span></strong></p>
<p><span class="example"><strong><span style="font-family:&#34;"><span style="font-size:x-small;"><span>  </span>sh<span>      </span>Invoke shell</span></span></strong></span> <span class="example"><strong><span style="font-family:&#34;"><span style="font-size:x-small;"><span>  </span></span></span></strong></span></p>
<p><span class="example"><strong><span style="font-family:&#34;"><span style="font-size:x-small;">vi<span>      </span>Vi mode</span></span></strong></span> <span class="example"><strong><span style="font-family:&#34;"><span style="font-size:x-small;"><span>  </span></span></span></strong></span></p>
<p><span class="example"><strong><span style="font-family:&#34;"><span style="font-size:x-small;">wq<span>      </span>Write and quit</span></span></strong></span> <span class="example"><strong><span style="font-family:&#34;"><span style="font-size:x-small;"><span>  </span></span></span></strong></span></p>
<p><span class="example"><strong><span style="font-family:&#34;"><span style="font-size:x-small;">w &#60;f&#62;<span>   </span>Write file &#60;f&#62;</span></span></strong></span> <span style="font-size:x-small;"><span class="example"><strong><span style="font-family:&#34;"><span>  </span></span></strong></span></span></p>
<p><span style="font-size:x-small;"><span class="example"><strong><span style="font-family:&#34;">w! &#60;f&#62;<span>  </span>Overwrite file &#60;f&#62;</span></strong></span><strong></strong></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;" lang="EN"><span style="font-family:Times New Roman;"> </span></span></p>
<table style="border-collapse:collapse;" border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td style="width:3.45in;background-color:transparent;border:windowtext 0.5pt solid;padding:0 5.4pt;" colspan="2" width="331" valign="top">
<h3 style="margin:auto 0;"><span style="font-weight:normal;font-size:10pt;" lang="EN"><span style="font-family:Times New Roman;">Ex mode commands:</span></span></h3>
</td>
</tr>
<tr>
<td style="border-right:windowtext 0.5pt solid;border-top:#ece9d8;border-left:windowtext 0.5pt solid;width:77.4pt;border-bottom:windowtext 0.5pt solid;background-color:transparent;padding:0 5.4pt;" width="103" valign="top">
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">q<span>    </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">q!<span>    </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">r &#60;f&#62;</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">set &#60;x&#62;<span>   </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">set no&#60;v&#62; </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">set all<span>   </span></span></span></p>
</td>
<td style="border-right:windowtext 0.5pt solid;border-top:#ece9d8;border-left:#ece9d8;width:171pt;border-bottom:windowtext 0.5pt solid;background-color:transparent;padding:0 5.4pt;" width="228" valign="top">
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">Quit<span>                 </span><span> </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;"><span> </span>Quit, discard changes </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;"><span> </span>Read in file &#60;f&#62;<span>      </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;">Enable option</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;"><span> </span>Disable option</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#008000;"><span style="font-family:Times New Roman;"><span> </span>Show all options</span></span></p>
</td>
</tr>
</tbody>
</table>
<pre><span class="example"><span lang="EN"><span style="font-size:x-small;"><span>      </span></span></span></span>
<span class="example"><span lang="EN"><span><span style="font-size:x-small;">      </span></span></span></span></pre>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Unix Shell Scripting]]></title>
<link>http://irfanworld.wordpress.com/?p=59</link>
<pubDate>Tue, 16 Sep 2008 07:13:06 +0000</pubDate>
<dc:creator>Irfan</dc:creator>
<guid>http://irfanworld.it.wordpress.com/2008/09/16/unix-shell-scripting/</guid>
<description><![CDATA[This post will help administrator and novice UNIX programmer to understand and write strong as well ]]></description>
<content:encoded><![CDATA[<p class="MsoNormal"><span style="font-size:10pt;font-family:Arial;">This post will help administrator and novice UNIX programmer to understand and write strong as well as useful shell programs. I will talks on shell syntax and few simple day-to-day utilities for UNIX. Will discussing mainly Bourn shell because of its widely acclaimed popularity and usage among the UNIX world.</span></p>
<p class="MsoNormal"><span style="font-size:10pt;font-family:Arial;">Many standard utilities (rdist, make, cron, etc.) allow you to specify a command to run at a certain time. Usually, this command is simply passed to the Bourne shell, which means that you can execute whole scripts, should you choose to do so. Steve Bourne, wrote the Bourne shell which appeared in the Seventh Edition Bell Labs Research version of Unix. </span></p>
<p class="MsoNormal"><span style="font-size:10pt;font-family:Arial;">Lastly, UNIX runs Bourne shell scripts when it boots. If you want to modify the boot-time behavior of a system, you need to learn to write and modify Bourne shell scripts. It said there are 95% shell code written in Bourne shell. Code written in Bourne shell is compatible with shell scripting like ksh, bash &#38; zsh. That means with minimal or no change one could port shell script written in Bourne shell to ksh or bash or zsh.</span></p>
<p class="MsoNormal"><span style="font-size:10pt;font-family:Arial;">*Bash is popular among Linux users. </span></p>
<p class="MsoNormal"><span style="font-size:10pt;font-family:Arial;">There are couple of other shells available which I will not be talking are C shell ( Used by C program to create programming rich shell) this is incompatible to Bourne shell. The C shell, csh, and its variant tcsh is a fine interactive shell (I use tcsh), but is a lousy shell for writing scripts.</span></p>
<p class="MsoNormal"><span style="font-size:10pt;font-family:Arial;">Lets understand what is an executable files, they also know as program or binary executables, This files are machine readable files and human eyes can not make sense out of it. Others only contain text, knows as script. They are interpreter scripts like awk, sed, perl and many more.</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;"> </span></p>
<h3><span>Learning Shell Scripting</span></h3>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">#!/bin/sh</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">The first line of any script must begin with #!, followed by the name of the interpreter. Some versions of UNIX allow whitespace between #! and the name of the interpreter. Others do not. Hence, if you want your script to be portable, leave out the blank.</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;"> </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">A script, like any file that can be run as a command, needs to be executable: save this script as rotatelog and run</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">chmod +x rotatelog<br />
to make it executable.</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;"> </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">You can now run it by running<br />
./rotatelog</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;"> </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">Unlike some other operating systems, UNIX allows any program to be used as a script interpreter. This is why people talk about ``a Bourne shell script'' or ``an awk script.'' One might even write a more script, or an ls script (though the latter wouldn't be terribly useful). Hence, it is important to let Unix know which program will be interpreting the script.</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">When Unix tries to execute the script, it sees the first two characters (#!) and knows that it is a script. It then reads the rest of the line to find out which program is to execute the script. For a Bourne shell script, this will be /bin/sh. Hence, the first line of our script must be</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">#!/bin/sh</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">After the command interpreter, you can have one, and sometimes more, options. Some flavors of Unix only allow one, though, so don't assume that you can have more.</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;"> </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;"> </span></p>
<h3>Variables</h3>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">sh allows you to have variables, just like any programming languages. Variables do not need to be declared. </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">To set a sh variable, use VAR=value</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">And to use the value of the variable later, use $VAR or ${VAR}</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">The latter syntax is useful if the variable name immediately followed by other text:</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">#!/bin/sh </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">COLOR=yellow </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">echo This looks $COLORish </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">echo This seems ${COLOR}ish</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">prints</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">This looks </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">This seems yellowish</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">There is only one type of variable in sh: strings. </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">This is somewhat limited, but is sufficient for most purposes.</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;"> </span></p>
<h3>Local vs. environment variables</h3>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">A sh variable can be either a local variable or an environment variable. They both work the same way; the only difference lies in what happens when the script runs another program (which, as we saw earlier, it does all the time).</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">Environment variables are passed to subprocesses. Local variables are not.</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">By default, variables are local. To turn a local variable into an environment variable, </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">use</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">export VAR</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">Here's a simple wrapper for a program:</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">#!/bin/sh </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">NETSCAPE_HOME=/usr/imports/libdata </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">CLASSPATH=$NETSCAPE_HOME/classes </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">export CLASSPATH $NETSCAPE_HOME/bin/netscape.bin</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">Here, NETSCAPE_HOME is a local variable; CLASSPATH is an environment variable. CLASSPATH will be passed to netscape.bin (netscape.bin uses the value of this variable to find Java class files); NETSCAPE_HOME is a convenience variable that is only used by the wrapper script; netscape.bin doesn't need to know about it, so it is kept local.</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">The only way to unexport a variable is to unset it:</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">unset VAR</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">This removes the variable from the shell's symbol table, effectively making as if it had never existed; as a side effect, the variable is also unexported.</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">Also, if you have a function by the same name as the variable, unset will also delete that function. Since you may want to use this variable later, it is better not to define it in the first place.</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">Also, note that if a variable was passed in as part of the environment, it is already an environment variable when your script starts running. If there is a variable that you really don't want to pass to any subprocesses, you should unset it near the top of your script. This is rare, but it might conceivably happen.</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">If you refer to a variable that hasn't been defined, sh substitutes the empty string.</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">#!/bin/sh </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">echo aaa $FOO bbb </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">echo xxx${FOO}yyy</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">prints</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">aaa bbb xxxyyy</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;"> </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;"> </span></p>
<h3>Special variables</h3>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">sh treats certain variables specially: some are set for you when your script runs, and some affect the way commands are interpreted.</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">Command-line arguments</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">The most useful of these variables are the ones referring to the command-line arguments. $1 refers to the first command-line argument (after the name of the script), $2 refers to the second one, and so forth, up to $9.</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">If you have more than nine command-line arguments, you can use the shift command: this discards the first command-line argument, and bumps the remaining ones up by one position: $2 becomes $1, $8 becomes $7, and so forth.</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">The variable $0 (zero) contains the name of the script (argv[0] in C programs).</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">Often, it is useful to just list all of the command-line arguments. </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">For this, sh provides the variables $* (star) and $@ (at). Each of these expands to a string containing all of the command-line arguments, as if you had used $1 $2 $3...</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">The difference between $* and $@ lies in the way they behave when they occur inside <a href="#double-quotes" target="_blank"><span style="text-decoration:none;color:#000000;">double quotes</span></a>: $* behaves in the normal way, whereas $@ creates a separate double-quoted string for each command-line argument. </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">That is, "$*" behaves as if you had written "$1 $2 $3", whereas "$@" behaves as if you had written "$1" "$2" "$3".</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">Finally, $# contains the number of command-line arguments that were given.</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">Other special variables</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">$? gives the exit status of the last command that was executed. This should be zero if the command exited normally.</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">$- lists all of the options with which sh was invoked. See sh(1) for details.</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">$$ holds the PID of the current process.</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">$! holds the PID of the last command that was executed in the background.</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">$IFS (Input Field Separator) determines how sh splits strings into words.</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;"> </span></p>
<h3>Quasi-variable constructs</h3>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">The ${VAR} construct is actually a special case of a more general class of constructs:</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">${VAR:-expression} </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">Use default value: if VAR is set and non-null, expands to $VAR. Otherwise, expands to expression. </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">${VAR:=expression} </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">Set default value: if VAR is set and non-null, expands to $VAR. Otherwise, sets VAR to expression and expands to expression. </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">${VAR:?[expression]} </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">If VAR is set and non-null, expands to $VAR. Otherwise, prints expression to standard error and exits with a non-zero exit status. </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">${VAR:+expression} </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">If VAR is set and non-null, expands to the empty string. Otherwise, expands to expression. </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">${#VAR} </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">Expands to the length of $VAR. </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">The above patterns test whether VAR is set and non-null. Without the colon, they only test whether VAR is set.</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;"> </span></p>
<h3>Pattern-matching</h3>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">sh supports a limited form of pattern-matching. The operators are</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">* Matches zero or more characters. </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">? Matches exactly one character. </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">[range] Matches any character in range. </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">Range can be either a list of characters that match, or two endpoints separated by a dash: [ak3] matches either a, k, or 3; [a-z] matches any character in the range a through z; [a-mz] matches either a character in the range a through m, or z. If you wish to include a dash as part of the range, it must be the first character, e.g., [-p] will match either a dash or p. </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">When an expression containing these characters occurs in the middle of a command, sh substitutes the list of all files whose name matches the pattern. This is known as ``globbing.'' Otherwise, these are used mainly in the <a href="#case" target="_blank"><span style="text-decoration:none;color:#000000;">case</span></a> construct.</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">As a special case, when a glob begins with * or ?, it does not match files that begin with a dot. To match these, you need to specify the dot explicitly (e.g., .*, /tmp/.*).</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">Note to MS-DOS users: under MS-DOS, the pattern *.* matches every file. In sh, it matches every file that contains a dot.</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;"> </span></p>
<h3>Quoting</h3>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">If you say something like</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">echo * MAKE $$$ FAST *</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">it won't do what you want: first of all, sh will expand the *s and replace them with a list of all the files in the current directory. Then, since any number of tabs or blanks can separate words, it will compress the three spaces into one. Finally, it will replace the first instance of $$ with the PID of the shell. This is where quoting comes in.</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">sh supports several types of quotes. Which one you use depends on what you want to do.</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">Backslash</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">Just as in C strings, a backslash (``\'') removes any special meaning from the character that follows. If the character after the backslash isn't special to begin with, the backslash has no effect. The backslash is itself special, so to escape it, just double it: \\.</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">Single quotes</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">Single quotes, such as 'foo' work pretty much the way you'd expect: anything inside them (except a single quote) is quoted. </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">You can say</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">echo '* MAKE $$$ FAST *'</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">and it'll come out the way you want it to.</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">Note that a backslash inside single quotes also loses its special meaning, so you don't need to double it. There is no way to have a single quote inside single quotes.</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">Double quotes, such as</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">"foo"</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">preserve spaces and most special characters. However, variables and <a href="#backquote" target="_blank"><span style="text-decoration:none;color:#000000;">backquoted expressions</span></a> are expanded and replaced with their value.</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">If you have an expression within backquotes (also known as backticks), e.g.,</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">`cmd`</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">the expression is evaluated as a command, and replaced with whatever the expression prints to its standard output. Thus,</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">echo You are `whoami`</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">prints</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">You are irfan</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;"> </span></p>
<h3>Built-in commands</h3>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">sh understands several built-in commands, i.e., commands that do not correspond to any program. These commands include:</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">{ commands ; }, ( commands ) </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">Execute commands in a subshell. That is, run them as if they were a single command. This is useful when <a href="#io-redirection" target="_blank"><span style="text-decoration:none;color:#000000;">I/O redirection</span></a> is involved, since you can pipe data to or from a mini-script inside a pipeline.</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">The { commands; } variant is somewhat more efficient, since it doesn't spawn a true subshell. This also means that if you set variables inside of it, the changes will be visible in the rest of the script. </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">: (colon) </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">Does nothing. This is generally seen as </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">: ${VAR:=default}</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">. filename </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">The dot command reads in the specified filename, as if it had occurred at that place in the script. </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">bg [job], fg [job] </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">bg runs the specified job (or the current job, if none is specified) in the background. fg resumes the specified job (or the current job, if none is specified) in the foreground. </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">Jobs are specified as %number. The jobs command lists jobs. </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">cd [dir] </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">Sets the current directory to dir. If dir is not specified, sets the current directory to the home directory. </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">pwd </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">Prints the current directory. </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">echo args </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">Prints args to standard output. </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">eval args </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">Evaluates args as a sh expression. This allows you to construct a string on the fly (e.g., using a variable that holds the name of a variable that you want to set) and execute it. </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">exec command </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">Runs the specified command, and replaces the current shell with it. That is, nothing after the exec statement will be executed, unless the exec itself fails. </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">exit [n] </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">Exit the current shell with exit code n. This defaults to zero. </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">kill [-sig] %job </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">Send signal sig to the specified job. sig can be either numeric or symbolic. kill -l lists all available signals. By default, sig is SIGTERM (15). </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">read name... </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">Reads one line from standard input and assigns it to the variable name. If several variables name1, name2, name3 etc. are specified, then the first word of the line read is assigned to name1, the second to name2, and so forth. Any remaining words are assigned to the last variable. </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">set [+/-flag] [arg] </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">With no arguments, prints the values of all variables.set -x turns on the x option to sh; set +x turns it off.set args... sets the command-line arguments to args.</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">test expression </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">Evaluates a boolean expression and exits with an exit code of zero if it is true, or non-zero if it is false. See <a href="#test" target="_blank"><span style="text-decoration:none;color:#000000;">test</span></a> for more details. </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">trap [command sig]... </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">If signal sig is sent to the shell, execute command. This is useful for exiting cleanly (e.g., removing temporary files etc.) when the script is interrupted. </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">ulimit </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">Print or set system limits on resource usage. </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">umask [nnn] </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">Sets the umask to nnn (an octal number). With no argument, prints the current umask. This is most useful when you want to create files, but want to restrict who can read or write them. </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">wait [n] </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">Wait for the background process whose PID is n to terminate. With no arguments, waits for all of the background processes to terminate. </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">Bear in mind that the list of builtins varies from one implementation to another, so don't take this list as authoritative.</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;"> </span></p>
<h3>Flow control</h3>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">sh supports several flow-control constructs, which add power and flexibility to your scripts.</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:14pt;font-family:Verdana;">if</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">The if statement is a simple conditional. You've seen it in every programming language. Its syntax is</span></p>
<p style="margin:0 0 .0001pt .5in;"><span style="font-size:10pt;font-family:Arial;">if condition ; then<br />
commands<br />
[elif condition ; then<br />
commands]...<br />
[else<br />
commands]<br />
fi</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">That is, an if-block, optionally followed by one or more elif-blocks (elif is short for ``else if''), optionally followed by an else-block, and terminated by fi.</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">The if statement pretty much does what you'd expect: if condition is true, it executes the if-block. Otherwise, it executes the else-block, if there is one. The elif construct is just syntactic sugar, to let you avoid nesting multiple if statements.</span></p>
<p style="margin:0 0 .0001pt .5in;"><span style="font-size:10pt;font-family:Arial;">#!/bin/sh </span></p>
<p style="margin:0 0 .0001pt .5in;"><span style="font-size:10pt;font-family:Arial;">myname=`whoami` </span></p>
<p style="margin:0 0 .0001pt .5in;"><span style="font-size:10pt;font-family:Arial;">if [ $myname = root ]; then </span></p>
<p style="margin:0 0 .0001pt 1in;"><span style="font-size:10pt;font-family:Arial;">echo "Welcome to FooSoft 3.0" </span></p>
<p style="margin:0 0 .0001pt .5in;"><span style="font-size:10pt;font-family:Arial;">else </span></p>
<p style="margin:0 0 .0001pt 1in;"><span style="font-size:10pt;font-family:Arial;">echo "You must be root to run this script" </span></p>
<p style="margin:0 0 .0001pt 1in;"><span style="font-size:10pt;font-family:Arial;">exit 1 </span></p>
<p style="margin:0 0 .0001pt .5in;"><span style="font-size:10pt;font-family:Arial;">fi</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">The more observant among you (or those who are math majors) are thinking, ``Hey! You forgot to include the square brackets in the syntax definition!''</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">Actually, I didn't: [ is actually a command, /bin/[, and is another name for the test command. See <a href="#test" target="_blank"><span style="text-decoration:none;color:#000000;">below</span></a> for details.</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">This is why you shouldn't call a test program test: if you have ``.'' at the end of your path, as you should, executing test will run /bin/test.</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">The condition can actually be any command. If it returns a zero exit status, the condition is true; otherwise, it is false. Thus, you can write things like</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">#!/bin/sh </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">user=arnie </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">if grep $user /etc/passwd; then </span></p>
<p style="margin:0 0 .0001pt .5in;"><span style="font-size:10pt;font-family:Arial;">echo "$user has an account" </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">else </span></p>
<p style="margin:0 0 .0001pt .5in;"><span style="font-size:10pt;font-family:Arial;">echo "$user doesn't have an account" </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">fi</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;"> </span></p>
<h3>while</h3>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">The while statement should also be familiar to you from any number of other programming languages. Its syntax in sh is</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">while condition; do<br />
commands<br />
done</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">As you might expect, the while loop executes commands as long as condition is true. Again, condition can be any command, and is true if the command exits with a zero exit status.</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">A while loop may contain two special commands: break and continue.</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">break exits the while loop immediately, jumping to the next statement after the done.</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">continue skips the rest of the body of the loop, and jumps back to the top, to where condition is evaluated.</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;"> </span></p>
<h3>for</h3>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">The for loop iterates over all of the elements in a list. Its syntax is</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">for var in list; do<br />
commands<br />
done</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">list is zero or more words. The for construct will assign the variable var to each word in turn, then execute commands. For example:</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">#!/bin/sh </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">for i in foo bar baz "do be do"; do </span></p>
<p style="margin:0 0 .0001pt .5in;"><span style="font-size:10pt;font-family:Arial;">echo "$i" </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">done</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">will print</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">foo bar baz do be do</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">A for loop may also contain break and continue statements. They work the same way as in the while loop.</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;"> </span></p>
<h3>Case</h3>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">The case construct works like C's switch statement, except that it matches patterns instead of numerical values. Its syntax is</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">case expression in<br />
pattern)<br />
commands<br />
;;<br />
...<br />
esac</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">expression is a string; this is generally either a variable or a backquoted command.</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">pattern is a glob pattern (see <a href="#globbing" target="_blank"><span style="text-decoration:none;color:#000000;">globbing</span></a>).</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">The patterns are evaluated in the order in which they are seen, and only the first pattern that matches will be executed. Often, you'll want to include a ``none of the above'' clause; to do this, use * as your last pattern.</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;"> </span></p>
<h3>IO</h3>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">A command's input and/or output may be redirected to another command or to a file. By default, every process has three file descriptors: standard input (0), standard output (1) and standard error (2). By default, each of these is connected to the user's terminal.</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">However, one can do many interesting things by redirecting one or more file descriptor:</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">&#60; filename </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">Connect standard input to the file filename. This allows you to have a command read from the file, rather than having to type its input in by hand. </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">&#62; filename </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">Connect standard output to the file filename. This allows you to save the output of a command to a file. If the file does not exist, it is created. If it does exist, it is emptied before anything happens. </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">(Exercise: why doesn't cat * &#62; zzzzzzz work the way you'd expect?)</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">&#62;&#62; filename </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">Connects standard output to the file filename. Unlike &#62;, however, the output of the command is appended to filename. </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">&#60;&#60;word </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">This construct isn't used nearly as often as it could be. It causes the command's standard input to come from... standard input, but only until word appears on a line by itself. Note that there is no space between &#60;&#60; and word.</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">This can be used as a mini-file within a script, e.g., </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">cat &#62; foo.c &#60;&#60;EOT </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">#include &#60;stdio.h&#62; </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">main() { </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">printf("Hello, world!\n"); </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">} EOT</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">It is also useful for printing multiline messages, e.g.:</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">line=13 cat &#60;&#60;EOT An error occurred on line $line. See page 98 of the manual for details. EOT</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">As this example shows, by default, &#60;&#60; acts like double quotes (i.e., variables are expanded). If, however, word is quoted, then &#60;&#60; acts like single quotes.</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">&#60;&#38;digit </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">Use file descriptor digit as standard input. </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">&#62;&#38;digit </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">Use file descriptor digit as standard output. </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">&#60;&#38;- </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">Close standard input. </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">&#62;&#38;- </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">Close standard output. </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">command1 &#124; command2 </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">Creates a pipeline: the standard output of command1 is connected to the standard input of command2. This is functionally identical to </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">command1 &#62; /tmp/foo<br />
command2 &#60; /tmp/foo</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">except that no temporary file is created, and both commands can run at the same time</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">There is a proverb that says, ``A temporary file is just a pipe with an attitude and a will to live.'' Any number of commands can be pipelined together.</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">command1 &#38;&#38; command2 </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">Execute command1. Then, if it exited with a zero (true) exit status, execute command2. </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">command1 &#124;&#124; command2 </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">Execute command1. Then, if it exited with a non-zero (false) exit status, execute command2. </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">If any of the redirection constructs is preceded by a digit, then it applies to the file descriptor with that number, rather than the default (0 or 1, as the case may be). For instance,</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">command 2&#62;&#38;1 &#62; filename</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">associates file descriptor 2 (standard error) with the same file as file descriptor 1 (standard output), then redirects both of them to filename.</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">This is also useful for printing error messages:</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">echo "Danger! Danger Will Robinson!" 1&#62;&#38;2</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">Note that I/O redirections are parsed in the order they are encountered, from left to right. This allows you to do fairly tricky things, including throwing out standard output, and piping standard output to a command.</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;"> </span></p>
<h3>Functions</h3>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">When a group of commands occurs several times in a script, it is useful to define a function. Defining a function is a lot like creating a mini-script within a script.</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">A function is defined using</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">name () {<br />
commands<br />
}</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">and is invoked like any other command:</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">name args...</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">You can redirect a function's I/O, embed it in backquotes, etc., just like any other command.</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">One way in which functions differ from external scripts is that the shell does not spawn a subshell to execute them. This means that if you set a variable inside a function, the new value will be visible outside of the function.</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">A function can use return n to terminate with an exit status of n. Obviously, it can also exit n, but that would terminate the entire script.</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">Function arguments</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">A function can take command-line arguments, just like any script. Intuitively enough, these are available through $1, $2... $9 just like the main script.</span></p>
<h3>Useful utilities</h3>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">There are a number of commands that aren't part of sh, but are often used inside sh scripts. These include:</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">basename</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">basename pathname prints the last component of pathname:</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">basename /foo/bar/baz</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">prints</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">baz</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">dirname</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">The complement of basename: dirname pathname prints all but the last component of pathname, that is the directory part: pathname:</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">dirname /foo/bar/baz</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">prints</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">/foo/bar</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">/bin/[ is another name for /bin/test. It evaluates its arguments as a boolean expression, and exits with an exit code of 0 if it is true, or 1 if it is false.</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">If test is invoked as [, then it requires a closing bracket ] as its last argument. Otherwise, there must be no closing bracket.</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">test understands the following expressions, among others:</span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">-e filename </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">True if filename exists. </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">-d filename </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">True if filename exists and is a directory. </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">-f filename </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">True if filename exists and is a plain file. </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">-h filename </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">True if filename exists and is a symbolic link. </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">-r filename </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">True if filename exists and is readable. </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">-w filename </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">True if filename exists and is writable. </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">-n string </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">True if the length of string is non-zero. </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">-z string </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">True if the length of string is zero. </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">string </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">True if string is not the empty string. </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">s1 = s2 </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">True if the strings s1 and s2 are identical. </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">s1 != s2 </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">True if the strings s1 and s2 are not identical. </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">n1 -eq n2 </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">True if the numbers n1 and n2 are equal. </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">n1 -ne n2 </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">True if the numbers n1 and n2 are not equal. </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">n1 -gt n2 </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">True if the number n1 is greater than n2. </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">n1 -ge n2 </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">True if the number n1 is greater than or equal to n2. </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">n1 -lt n2 </span></p>
<p style="margin:0 0 .0001pt;"><span style="font-size:10pt;font-family:Arial;">True if the number n1 is less than n2. </span></p>
<p style="margin:0 