<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Cosu &#187; Unix</title>
	<atom:link href="http://cosu.ro/blog/tag/unix/feed/" rel="self" type="application/rss+xml" />
	<link>http://cosu.ro/blog</link>
	<description>"I'm even greater than I thought I was", Bender Bending Rodríguez , Futurama, S05E01</description>
	<lastBuildDate>Wed, 12 Oct 2011 13:35:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Parsing XML data using bash and standard Unix tools</title>
		<link>http://cosu.ro/blog/2010/02/13/parsing-xml-data-using-bash-and-standard-unix-tools/</link>
		<comments>http://cosu.ro/blog/2010/02/13/parsing-xml-data-using-bash-and-standard-unix-tools/#comments</comments>
		<pubDate>Fri, 12 Feb 2010 23:53:24 +0000</pubDate>
		<dc:creator>Cosu</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Unix]]></category>

		<guid isPermaLink="false">http://cosu.ro/blog/2010/02/13/parsing-xml-data-using-bash-and-standard-unix-tools/</guid>
		<description><![CDATA[Parsing XML can be a tedious and unpleasant job if you insist on using just standard Unix tools like sed, awk, cut, grep and so on. One might say that it&#8217;s better to use python/perl/ruby/other language that ships with a full blown XML parser and use the standard Unix utilites for what they were meant [...]]]></description>
			<content:encoded><![CDATA[<p>Parsing XML can be a tedious and unpleasant job if you insist on using just standard Unix tools like sed, awk, cut, grep and so on. One might say that it&#8217;s better to use python/perl/ruby/other language that ships with a full blown XML parser and use the standard Unix utilites for what they were meant for, plain old text files and not pesky XML. The problem with those nice programming languages is that they take away the one liners. You need to import stuff, have variables, flow control and so on.</p>
<p>A nice tool that makes one&#8217;s life easier when it comes to XML is XML2. It can convert a normal xml file to a more line oriented file format. The standard debian distribution has this neat tool in the repos so you are one apt-get away from using it.</p>
<p> </p>
<p>One simple example. Take this XML file:</p>
<p><code><br />
&lt;xml&gt;<br />
&lt;fruits&gt;<br />
        &lt;fruit name=&quot;apple&quot; type=&quot;royal gala&quot; quantity=&quot;2&quot; price=&quot;1&quot;/&gt;<br />
        &lt;fruit name=&quot;orange&quot; type=&quot;tasty&quot; quantity=&quot;4&quot; price=&quot;1.5&quot;/&gt;<br />
        &lt;fruit name=&quot;banana&quot; type=&quot;green&quot; quantity=&quot;3&quot; price=&quot;1&quot;/&gt;<br />
&lt;/fruits&gt;<br />
&lt;/xml&gt;<br />
</code></p>
<p>We run xml2 against it:<br /> <code><br /> cosu@roadwarrior:/tmp$ xml2 &lt; fruits.xml<br /> /xml/fruits/fruit/@name=apple<br /> /xml/fruits/fruit/@type=royal gala<br /> /xml/fruits/fruit/@quantity=2<br /> /xml/fruits/fruit/@price=1<br /> /xml/fruits/fruit<br /> /xml/fruits/fruit/@name=orange<br /> /xml/fruits/fruit/@type=tasty<br /> /xml/fruits/fruit/@quantity=4<br /> /xml/fruits/fruit/@price=1.5<br /> /xml/fruits/fruit<br /> /xml/fruits/fruit/@name=banana<br /> /xml/fruits/fruit/@type=green<br /> /xml/fruits/fruit/@quantity=3<br /> /xml/fruits/fruit/@price=1<br /> </code><br /> And now we extract all the fruit names:<br /> <code><br /> cosu@roadwarrior:/tmp$ xml2 &lt; fruits.xml |grep name |cut -d"=" -f2<br /> apple<br /> orange<br /> banana<br /> </code></p>
<p>There you go! A fruit salad! Of course for more complicated stuff use other tools <img src='http://cosu.ro/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p> </p>
]]></content:encoded>
			<wfw:commentRss>http://cosu.ro/blog/2010/02/13/parsing-xml-data-using-bash-and-standard-unix-tools/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Unix toolbox</title>
		<link>http://cosu.ro/blog/2008/03/23/unix-toolbox/</link>
		<comments>http://cosu.ro/blog/2008/03/23/unix-toolbox/#comments</comments>
		<pubDate>Sun, 23 Mar 2008 08:28:17 +0000</pubDate>
		<dc:creator>Cosu</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Unix]]></category>

		<guid isPermaLink="false">http://cosu.ro/blog/2008/03/23/unix-toolbox/</guid>
		<description><![CDATA[Anumite lucruri nu ai cum sa le tii minte. Pentru asta exista man pages, carti, manuale, tutoriale, how-to-uri sau linkul asta]]></description>
			<content:encoded><![CDATA[<p>Anumite lucruri nu ai cum sa le tii minte. Pentru asta exista man pages, carti, manuale, tutoriale, how-to-uri sau <a href="http://cb.vu/unixtoolbox.xhtml" target="_blank">linkul asta</a></p>
]]></content:encoded>
			<wfw:commentRss>http://cosu.ro/blog/2008/03/23/unix-toolbox/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>File System History</title>
		<link>http://cosu.ro/blog/2008/03/19/file-system-history/</link>
		<comments>http://cosu.ro/blog/2008/03/19/file-system-history/#comments</comments>
		<pubDate>Wed, 19 Mar 2008 21:44:30 +0000</pubDate>
		<dc:creator>Cosu</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[OS X]]></category>
		<category><![CDATA[Unix]]></category>

		<guid isPermaLink="false">http://cosu.ro/blog/2008/03/19/file-system-history/</guid>
		<description><![CDATA[Ars Tehnica are un super articol care trece prin mai toate file systemurile importante de la Burebista si pana acum. Detaliile de implementare sunt minime asa ca e o lectura placuta de seara. Recomandat! Si un citat din Linus Torvalds despre sistemul de fisiere de pe OS X:  &#8220;Their file system is complete and utter [...]]]></description>
			<content:encoded><![CDATA[<p>Ars Tehnica are un <a href="http://arstechnica.com/articles/paedia/past-present-future-file-systems.ars" target="_blank">super articol </a>care trece prin mai toate file systemurile importante de la Burebista si pana acum. Detaliile de implementare sunt minime asa ca e o lectura placuta de seara. Recomandat!</p>
<p>Si un citat din <em>Linus Torvalds</em> despre sistemul de fisiere de pe OS X:  &#8220;<em>Their file system is complete and utter crap, which is scary.</em>&#8220;</p>
]]></content:encoded>
			<wfw:commentRss>http://cosu.ro/blog/2008/03/19/file-system-history/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>30+ Reasons Why You Should Say MsDog and not MsDos.</title>
		<link>http://cosu.ro/blog/2008/03/01/30-reasons-why-you-should-say-msdog-and-not-msdos/</link>
		<comments>http://cosu.ro/blog/2008/03/01/30-reasons-why-you-should-say-msdog-and-not-msdos/#comments</comments>
		<pubDate>Sat, 01 Mar 2008 17:58:20 +0000</pubDate>
		<dc:creator>Cosu</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Unix]]></category>

		<guid isPermaLink="false">http://cosu.ro/blog/2008/03/01/30-reasons-why-you-should-say-msdog-and-not-msdos/</guid>
		<description><![CDATA[Cautand prin documentatia lui libc am dat peste urmatorul comentariu This function is not part of the ISO or POSIX standards, and is not customary on Unix systems, but we did not invent it either. Perhaps it comes from MS-DOG. Dupa cateva secunde eram pe jos de ras. Motivul este asta: http://www.delorie.com/djgpp/doc/msdog.html]]></description>
			<content:encoded><![CDATA[<p>Cautand prin documentatia lui libc am dat peste urmatorul comentariu</p>
<blockquote><p>This function is not part of the ISO or POSIX standards, and is not customary on Unix systems, but we did not invent it either.  Perhaps it comes from MS-DOG.</p></blockquote>
<p>Dupa cateva secunde eram pe jos de ras. Motivul este asta:</p>
<p><a href="http://www.delorie.com/djgpp/doc/msdog.html">http://www.delorie.com/djgpp/doc/msdog.html</a></p>
]]></content:encoded>
			<wfw:commentRss>http://cosu.ro/blog/2008/03/01/30-reasons-why-you-should-say-msdog-and-not-msdos/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

