<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>commandliners</title>
	
	<link>http://commandliners.com</link>
	<description># killall -9 X</description>
	<lastBuildDate>Mon, 09 Jan 2012 20:50:52 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/commandliners" /><feedburner:info uri="commandliners" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Greping from inside Vim</title>
		<link>http://feedproxy.google.com/~r/commandliners/~3/rLiOlehU-OA/</link>
		<comments>http://commandliners.com/2012/01/greping-from-inside-vim/#comments</comments>
		<pubDate>Mon, 09 Jan 2012 20:50:52 +0000</pubDate>
		<dc:creator>n0str0m0</dc:creator>
				<category><![CDATA[shell]]></category>
		<category><![CDATA[grep]]></category>
		<category><![CDATA[grepprg]]></category>
		<category><![CDATA[vim]]></category>

		<guid isPermaLink="false">http://commandliners.com/?p=2408</guid>
		<description><![CDATA[Hi there, First things first: Happy New Year! :) One task I usually perform when I am writing code is grepping the code for a certain string. In order to do that, I used to exit Vim (either with :q or suspending the process), grep the files and then go back to my Vim session. [...]]]></description>
			<content:encoded><![CDATA[<p>Hi there,<br />
First things first: Happy New Year! :)<br />
One task I usually perform when I am writing code is <i>grepping</i> the code for a certain string. In order to do that, I used to exit Vim (either with <i>:q</i> or suspending the process), grep the files and then go back to my Vim session. This approximation has one main drawback: I usually don&#8217;t remember all the matches reported by grep.<br />
Vim provides a mechanism for invoking grep from a Vim session. The command is:</p>
<pre><code>:grep string files</code></pre>
<p>This way, one can invoke his local grep command and the results will be integrated into the error list, the one we wrote about in <a href="http://commandliners.com/2010/01/vim-for-programmers-ii/" />compilation errors</a>. This way, one can move through the matching list using both <code>:cp</code> and <code>:cn</code><br />
We can instruct Vim to use another grep program by setting the <i>grepprg</i> variable.</p>
<img src="http://feeds.feedburner.com/~r/commandliners/~4/rLiOlehU-OA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://commandliners.com/2012/01/greping-from-inside-vim/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://commandliners.com/2012/01/greping-from-inside-vim/</feedburner:origLink></item>
		<item>
		<title>Unicode sorting in perl</title>
		<link>http://feedproxy.google.com/~r/commandliners/~3/Oa9vnhqj2c8/</link>
		<comments>http://commandliners.com/2011/11/unicode-sorting-in-perl/#comments</comments>
		<pubDate>Sat, 12 Nov 2011 17:51:28 +0000</pubDate>
		<dc:creator>pfortuny</dc:creator>
				<category><![CDATA[shell]]></category>
		<category><![CDATA[normalization]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[unicode]]></category>

		<guid isPermaLink="false">http://commandliners.com/?p=2392</guid>
		<description><![CDATA[Just Normalize. Assume file.txt is a list of unicode words, then cat file.txt &#124; perl -e 'use Unicode::Normalize; my @w ;\ while () {chomp; push @w, $_;} ; @w = sort {NFD($a) cmp NFD($b) } @w ;\ print(join("\n", @w))' will output the sorted list (well, sorted according to the NFD normalization, which for Spanish is [...]]]></description>
			<content:encoded><![CDATA[<p>Just Normalize. Assume <code>file.txt</code> is a list of unicode words, then</p>
<pre><code>cat file.txt | perl -e 'use Unicode::Normalize; my @w ;\
while (<>) {chomp; push @w, $_;} ; @w = sort {NFD($a) cmp NFD($b) } @w ;\
print(join("\n", @w))'</code></pre>
<p>will output the sorted list (well, sorted according to the NFD normalization, which for Spanish is enough).</p>
<img src="http://feeds.feedburner.com/~r/commandliners/~4/Oa9vnhqj2c8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://commandliners.com/2011/11/unicode-sorting-in-perl/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://commandliners.com/2011/11/unicode-sorting-in-perl/</feedburner:origLink></item>
		<item>
		<title>Creating shell archives</title>
		<link>http://feedproxy.google.com/~r/commandliners/~3/ledGEph6jSU/</link>
		<comments>http://commandliners.com/2011/10/creating-shell-archives/#comments</comments>
		<pubDate>Sat, 15 Oct 2011 19:38:52 +0000</pubDate>
		<dc:creator>n0str0m0</dc:creator>
				<category><![CDATA[shell]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[FreeBSD]]></category>
		<category><![CDATA[hierarchy]]></category>
		<category><![CDATA[shar]]></category>

		<guid isPermaLink="false">http://commandliners.com/?p=2377</guid>
		<description><![CDATA[shar(1) is a FreeBSD base system utility for creating shell archives that is, a kind of self-extracting archive of a hierarchy of files and directories. The archive will recreate the file hierarchy specified at creation time. It is fast and the result is easy to handle as the shell archive is a text file (good [...]]]></description>
			<content:encoded><![CDATA[<p><code>shar</code>(1) is a FreeBSD base system utility for creating shell archives that is, a kind of self-extracting archive of a hierarchy of files and directories. The archive will recreate the file hierarchy specified at creation time. It is fast and the result is easy to handle as the shell archive is a text file (good to email a file hierarchy).</p>
<p>To create a shell archive:</p>
<pre><code>$ shar `find my_directory` &gt; my_hierarchy.shar</code></pre>
<p>To recreate the hierarchy:</p>
<pre><code>$ sh my_hierarchy.shar</code></pre>
<p>That is, <code>shar</code> is a simpler version of <code>ar</code> and <code>tar</code>.</p>
<p>Enjoy!</p>
<img src="http://feeds.feedburner.com/~r/commandliners/~4/ledGEph6jSU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://commandliners.com/2011/10/creating-shell-archives/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://commandliners.com/2011/10/creating-shell-archives/</feedburner:origLink></item>
		<item>
		<title>How to know if a CPU is 32 or 64-bit</title>
		<link>http://feedproxy.google.com/~r/commandliners/~3/340cA-rSzJ4/</link>
		<comments>http://commandliners.com/2011/09/how-to-know-if-a-cpu-is-32-or-64-bit/#comments</comments>
		<pubDate>Thu, 22 Sep 2011 07:00:11 +0000</pubDate>
		<dc:creator>rafacas</dc:creator>
				<category><![CDATA[shell]]></category>
		<category><![CDATA[32bit]]></category>
		<category><![CDATA[64bit]]></category>
		<category><![CDATA[CPU]]></category>
		<category><![CDATA[grep]]></category>

		<guid isPermaLink="false">http://commandliners.com/?p=2301</guid>
		<description><![CDATA[Nowadays almost all the computers have a 64-bit CPU, but sometimes we are logged in on a remote server and do not know what kind of CPU it has and we need to know it to install a package or&#8230; out of mere curiosity. In those cases we can run the following command: $ grep [...]]]></description>
			<content:encoded><![CDATA[<p>Nowadays almost all the computers have a 64-bit CPU, but sometimes we are logged in on a remote server and do not know what kind of CPU it has and we need to know it to install a package or&#8230; out of mere curiosity.</p>
<p>In those cases we can run the following command:</p>
<pre><code>$ grep --color lm /proc/cpuinfo
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts
acpi mmx fxsr sse sse2 ss syscall nx rdtscp <span style="color: #ff0000;">lm</span> constant_tsc up ida nonstop_tsc arat pni
ssse3 cx16 sse4_1 sse4_2 popcnt lahf_<span style="color: #ff0000;">lm </span></code></pre>
<p>If the <code>lm</code> flag is present (i.e. if there is any output to the <code>grep</code> command), then the CPU is 64-bit. <code>lm</code> means <i>long mode</i> (64 bit extension).</p>
<img src="http://feeds.feedburner.com/~r/commandliners/~4/340cA-rSzJ4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://commandliners.com/2011/09/how-to-know-if-a-cpu-is-32-or-64-bit/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://commandliners.com/2011/09/how-to-know-if-a-cpu-is-32-or-64-bit/</feedburner:origLink></item>
		<item>
		<title>Resume rsync file transfers</title>
		<link>http://feedproxy.google.com/~r/commandliners/~3/obv4pI1DDv0/</link>
		<comments>http://commandliners.com/2011/09/resume-rsync-file-transfers/#comments</comments>
		<pubDate>Thu, 15 Sep 2011 07:00:35 +0000</pubDate>
		<dc:creator>rafacas</dc:creator>
				<category><![CDATA[network]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[rsync]]></category>

		<guid isPermaLink="false">http://commandliners.com/?p=2347</guid>
		<description><![CDATA[I did not know that rsync had the resume capability till last week when I had to transfer almost 200GB between two servers with no good connection. I think some context is needed here: My company has two servers in two different cities where the backups are stored. There is a daily syncronization between the [...]]]></description>
			<content:encoded><![CDATA[<p>I did not know that rsync had the <i>resume</i> capability till last week when I had to transfer almost 200GB between two servers with no good connection. I think some context is needed here: My company has two servers in two different cities where the backups are stored. There is a daily <i>syncronization</i> between the backup tree between the servers. That is, a cron task that calls a script that basically runs <code>rsync</code>.</p>
<p>Due to the bad connection, I have had to add the <code>-P</code> option to the <code>rsync</code> command so that the command run by the cron task is:</p>
<pre><code>$ rsync -rPtz -e ssh /local_backup_path/ remote_host:/remote_backup_path/
</code></pre>
<p>The <code>-e ssh</code> tells rsync to use a ssh client instead of rsh. The <code>-z</code> option compresses the file. <code>-t</code> preserves time attributes and the <code>-P</code> option resumes incomplete file transfers.</p>
<p>If you run this command from the command line you can use the <code>--progress</code> option, that will show you a progress bar during transfer. Very useful with large files.</p>
<p>I hope this saves you some time ;)</p>
<img src="http://feeds.feedburner.com/~r/commandliners/~4/obv4pI1DDv0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://commandliners.com/2011/09/resume-rsync-file-transfers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://commandliners.com/2011/09/resume-rsync-file-transfers/</feedburner:origLink></item>
		<item>
		<title>Audio settings on FreeBSD</title>
		<link>http://feedproxy.google.com/~r/commandliners/~3/4ER0S1NsjGg/</link>
		<comments>http://commandliners.com/2011/09/audio-settings-on-freebsd/#comments</comments>
		<pubDate>Tue, 13 Sep 2011 10:32:19 +0000</pubDate>
		<dc:creator>n0str0m0</dc:creator>
				<category><![CDATA[shell]]></category>
		<category><![CDATA[audio]]></category>
		<category><![CDATA[FreeBSD]]></category>
		<category><![CDATA[mixer]]></category>

		<guid isPermaLink="false">http://commandliners.com/?p=2367</guid>
		<description><![CDATA[mixer(8) is a FreeBSD base system utility for setting and displaying sound card mixer levels. It resembles the Linux&#8217;s command line utility alsamixer. Invoked with no parameters it shows the current values of the mixer devices: $ mixer Mixer vol is currently set to 85:85 Mixer pcm is currently set to 75:75 Mixer speaker is [...]]]></description>
			<content:encoded><![CDATA[<p><code>mixer</code>(8) is a FreeBSD base system utility for setting and displaying sound card mixer levels. It resembles the Linux&#8217;s command line utility <i>alsamixer</i>. Invoked with no parameters it shows the current values of the mixer devices:</p>
<pre><code>$ mixer
Mixer vol      is currently set to  85:85
Mixer pcm      is currently set to  75:75
Mixer speaker  is currently set to  75:75
Mixer mic      is currently set to   0:0
Mixer mix      is currently set to   0:0
Mixer rec      is currently set to  75:75
Mixer igain    is currently set to  75:75
Mixer monitor  is currently set to  75:75
Recording source: mic
</code></pre>
<p>Setting specific values is easy enough:</p>
<pre><code>$ mixer rec 80:80
Setting the mixer rec from 75:75 to 80:80.
</code></pre>
<p></p>
<p>Enjoy!</p>
<img src="http://feeds.feedburner.com/~r/commandliners/~4/4ER0S1NsjGg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://commandliners.com/2011/09/audio-settings-on-freebsd/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://commandliners.com/2011/09/audio-settings-on-freebsd/</feedburner:origLink></item>
		<item>
		<title>Changing permissions only in directories</title>
		<link>http://feedproxy.google.com/~r/commandliners/~3/iN9MBTQOj7k/</link>
		<comments>http://commandliners.com/2011/09/changing-permissions-only-in-directories/#comments</comments>
		<pubDate>Thu, 08 Sep 2011 07:00:33 +0000</pubDate>
		<dc:creator>rafacas</dc:creator>
				<category><![CDATA[cmd]]></category>
		<category><![CDATA[chmod]]></category>

		<guid isPermaLink="false">http://commandliners.com/?p=2293</guid>
		<description><![CDATA[$ chmod -R u+rX Changes recursively the write permissions only in the directories. It has been very useful to me lately and I have to admit I did not know this till some weeks ago.]]></description>
			<content:encoded><![CDATA[<pre><code>$ chmod -R u+rX</code></pre>
<p>Changes recursively the write permissions only in the directories. It has been very useful to me lately and I have to admit I did not know this till some weeks ago.</p>
<img src="http://feeds.feedburner.com/~r/commandliners/~4/iN9MBTQOj7k" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://commandliners.com/2011/09/changing-permissions-only-in-directories/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://commandliners.com/2011/09/changing-permissions-only-in-directories/</feedburner:origLink></item>
		<item>
		<title>Adding formatting to an XML document</title>
		<link>http://feedproxy.google.com/~r/commandliners/~3/3kC4nWi4t6U/</link>
		<comments>http://commandliners.com/2011/09/adding-formatting-to-an-xml-document/#comments</comments>
		<pubDate>Thu, 01 Sep 2011 07:00:27 +0000</pubDate>
		<dc:creator>rafacas</dc:creator>
				<category><![CDATA[shell]]></category>
		<category><![CDATA[format]]></category>
		<category><![CDATA[xml]]></category>
		<category><![CDATA[xmllint]]></category>

		<guid isPermaLink="false">http://commandliners.com/?p=2291</guid>
		<description><![CDATA[Sometimes, when I have to program a web service client I have to deal with unformatted XML files. For example, the next one: &#60;users&#62;&#60;user&#62;&#60;email&#62;pfortuny@commandliners.com&#60;/email&#62;&#60;passwd&#62;a0f901492d89fe2ba88cc96bf9d 2475e&#60;/passwd&#62;&#60;/user&#62;&#60;user&#62;&#60;email&#62;n0str0m0@commandliners.com&#60;/email&#62;&#60;passwd&#62;7e1b6dbfa824d 5d114e96981cededd00&#60;/passwd&#62;&#60;/user&#62;&#60;user&#62;&#60;email&#62;rafacas@commandliners.com&#60;/email&#62;&#60;passwd&#62; 70c1db56f301c9e337b0099bd4174b28&#60;/passwd&#62;&#60;/user&#62;&#60;/users&#62; This is not a bad thing, because it is sent that way to save traffic, but I&#8217;d rather see it in a human readable format. So I use [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes, when I have to program a web service client I have to deal with unformatted XML files. For example, the next one:</p>
<pre><code>&lt;users&gt;&lt;user&gt;&lt;email&gt;pfortuny@commandliners.com&lt;/email&gt;&lt;passwd&gt;a0f901492d89fe2ba88cc96bf9d
2475e&lt;/passwd&gt;&lt;/user&gt;&lt;user&gt;&lt;email&gt;n0str0m0@commandliners.com&lt;/email&gt;&lt;passwd&gt;7e1b6dbfa824d
5d114e96981cededd00&lt;/passwd&gt;&lt;/user&gt;&lt;user&gt;&lt;email&gt;rafacas@commandliners.com&lt;/email&gt;&lt;passwd&gt;
70c1db56f301c9e337b0099bd4174b28&lt;/passwd&gt;&lt;/user&gt;&lt;/users&gt;</code></pre>
<p>This is not a bad thing, because it is sent that way to save traffic, but I&#8217;d rather see it in a <em>human readable</em> format. So I use the <code>xmllint</code> command, that reformat and reindent the input.</p>
<pre><code>$ xmllint --format test.xml
&lt;?xml version="1.0"?&gt;
&lt;users&gt;
  &lt;user&gt;
    &lt;email&gt;pfortuny@commandliners.com&lt;/email&gt;
    &lt;passwd&gt;a0f901492d89fe2ba88cc96bf9d2475e&lt;/passwd&gt;
  &lt;/user&gt;
  &lt;user&gt;
    &lt;email&gt;n0str0m0@commandliners.com&lt;/email&gt;
    &lt;passwd&gt;7e1b6dbfa824d5d114e96981cededd00&lt;/passwd&gt;
  &lt;/user&gt;
  &lt;user&gt;
    &lt;email&gt;rafacas@commandliners.com&lt;/email&gt;
    &lt;passwd&gt;70c1db56f301c9e337b0099bd4174b28&lt;/passwd&gt;
  &lt;/user&gt;
&lt;/users&gt; </code></pre>
<p>The indentation can be controlled by the environment variable <code>XMLLINT_INDENT</code>. The default value is two spaces.</p>
<p>pfortuny, n0str0m0, do not worry guys, those are not your passwords, are they? ;)</p>
<img src="http://feeds.feedburner.com/~r/commandliners/~4/3kC4nWi4t6U" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://commandliners.com/2011/09/adding-formatting-to-an-xml-document/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://commandliners.com/2011/09/adding-formatting-to-an-xml-document/</feedburner:origLink></item>
		<item>
		<title>Clearing the terminal screen</title>
		<link>http://feedproxy.google.com/~r/commandliners/~3/e_Pct7E-aBs/</link>
		<comments>http://commandliners.com/2011/08/clearing-the-terminal-screen/#comments</comments>
		<pubDate>Thu, 25 Aug 2011 07:00:38 +0000</pubDate>
		<dc:creator>rafacas</dc:creator>
				<category><![CDATA[cmd]]></category>
		<category><![CDATA[clear]]></category>
		<category><![CDATA[screen]]></category>

		<guid isPermaLink="false">http://commandliners.com/?p=2297</guid>
		<description><![CDATA[Ctrl + l Clears the terminal screen.]]></description>
			<content:encoded><![CDATA[<pre><code>Ctrl + l</code></pre>
<p>Clears the terminal screen.</p>
<img src="http://feeds.feedburner.com/~r/commandliners/~4/e_Pct7E-aBs" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://commandliners.com/2011/08/clearing-the-terminal-screen/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://commandliners.com/2011/08/clearing-the-terminal-screen/</feedburner:origLink></item>
		<item>
		<title>Determining if an XML document is well-formed</title>
		<link>http://feedproxy.google.com/~r/commandliners/~3/mY3okMl60Pk/</link>
		<comments>http://commandliners.com/2011/08/determining-if-an-xml-document-is-well-formed/#comments</comments>
		<pubDate>Thu, 18 Aug 2011 07:36:25 +0000</pubDate>
		<dc:creator>rafacas</dc:creator>
				<category><![CDATA[shell]]></category>
		<category><![CDATA[xml]]></category>
		<category><![CDATA[xmlwf]]></category>

		<guid isPermaLink="false">http://commandliners.com/?p=2314</guid>
		<description><![CDATA[After creating an XML document from scratch I always check if it is well-formed. This means it must adhere to a number of rules, including the following: Every start-tag must have a matching end-tag. Elements may nest, but may not overlap. There must be exactly one root element. Attribute values must be quoted. An element [...]]]></description>
			<content:encoded><![CDATA[<p>After creating an XML document from scratch I always check if it is well-formed. This means it must adhere to a number of rules, including the following:</p>
<ol>
<li>Every start-tag must have a matching end-tag.</li>
<li>Elements may nest, but may not overlap.</li>
<li>There must be exactly one root element.</li>
<li>Attribute values must be quoted.</li>
<li>An element may not have two attributes with the same name.</li>
</ol>
<p>This is not an exhaustive list and I do not mean to explain all the rules. There are many, many ways a document can be malformed. But if you need to determine if and XML document is well-formed there is a linux command for doing that: <code>xmlwf</code></p>
<pre><code>$xmlwf test.xml</code></pre>
<p>If there is no output, the document is well-formed. If it is not, the output will show you where the problem is:</p>
<pre><code>$ xmlwf test.xml
test.xml:4:38: mismatched tag
</code></pre>
<p>For more info <code>man xmlwf</code></p>
<img src="http://feeds.feedburner.com/~r/commandliners/~4/mY3okMl60Pk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://commandliners.com/2011/08/determining-if-an-xml-document-is-well-formed/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://commandliners.com/2011/08/determining-if-an-xml-document-is-well-formed/</feedburner:origLink></item>
	</channel>
</rss><!-- Dynamic Page Served (once) in 0.323 seconds -->

