<?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>/kb &#187; Shell</title>
	<atom:link href="http://grx.no/kb/category/shell/feed/" rel="self" type="application/rss+xml" />
	<link>http://grx.no/kb</link>
	<description>personal knowledgebase</description>
	<lastBuildDate>Mon, 06 Feb 2012 17:05:03 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>SSH aliases</title>
		<link>http://grx.no/kb/2010/06/18/ssh-aliases/</link>
		<comments>http://grx.no/kb/2010/06/18/ssh-aliases/#comments</comments>
		<pubDate>Fri, 18 Jun 2010 08:02:56 +0000</pubDate>
		<dc:creator>hgrimelid</dc:creator>
				<category><![CDATA[Server]]></category>
		<category><![CDATA[Shell]]></category>
		<category><![CDATA[password]]></category>
		<category><![CDATA[ssh]]></category>

		<guid isPermaLink="false">http://grx.no/kb/?p=198</guid>
		<description><![CDATA[In ~/.ssh/config add the following: Host ALIAS HostName DOMAIN User USERNAME Port PORT_NUMBER]]></description>
			<content:encoded><![CDATA[<p>In <code>~/.ssh/config</code> add the following:</p>

<div class="wp_syntax"><div class="code"><pre class="ssh" style="font-family:monospace;">Host ALIAS
HostName DOMAIN
User USERNAME
Port PORT_NUMBER</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://grx.no/kb/2010/06/18/ssh-aliases/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Compile Vim in Snow Leopard</title>
		<link>http://grx.no/kb/2010/04/28/compile-vim-in-snow-leopard/</link>
		<comments>http://grx.no/kb/2010/04/28/compile-vim-in-snow-leopard/#comments</comments>
		<pubDate>Wed, 28 Apr 2010 09:01:58 +0000</pubDate>
		<dc:creator>hgrimelid</dc:creator>
				<category><![CDATA[Editors]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Shell]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[vim]]></category>

		<guid isPermaLink="false">http://grx.no/kb/?p=196</guid>
		<description><![CDATA[./configure &#8211;enable-pythoninterp &#8211;with-macsdk=10.6 via Chris Moyer: OSX, Vim, and Python.]]></description>
			<content:encoded><![CDATA[<p>./configure &#8211;enable-pythoninterp &#8211;with-macsdk=10.6</p>
<p>via <a href="http://blog.coredumped.org/2010/01/osx-vim-and-python.html">Chris Moyer: OSX, Vim, and Python</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://grx.no/kb/2010/04/28/compile-vim-in-snow-leopard/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Git: Start a new branch after making changes</title>
		<link>http://grx.no/kb/2010/04/23/git-start-a-new-branch-after-making-changes/</link>
		<comments>http://grx.no/kb/2010/04/23/git-start-a-new-branch-after-making-changes/#comments</comments>
		<pubDate>Fri, 23 Apr 2010 10:39:39 +0000</pubDate>
		<dc:creator>hgrimelid</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Shell]]></category>
		<category><![CDATA[git]]></category>

		<guid isPermaLink="false">http://grx.no/kb/?p=189</guid>
		<description><![CDATA[Sometimes I realize that my latest changes actually should belong to another branch than the one I&#8217;m currently working on. The easy way to add the changes to a new branch is to use the stash command. &#91;… changes …&#93; git stash git stash branch name_of_new_branch git commit &#91;…&#93; git push origin name_of_new_branch Ref. git [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes I realize that my latest changes actually should belong to another branch than the one I&#8217;m currently working on. The easy way to add the changes to a new branch is to use the <code>stash</code> command.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>… changes …<span style="color: #7a0874; font-weight: bold;">&#93;</span>
<span style="color: #c20cb9; font-weight: bold;">git</span> stash
<span style="color: #c20cb9; font-weight: bold;">git</span> stash branch name_of_new_branch
<span style="color: #c20cb9; font-weight: bold;">git</span> commit <span style="color: #7a0874; font-weight: bold;">&#91;</span>…<span style="color: #7a0874; font-weight: bold;">&#93;</span>
<span style="color: #c20cb9; font-weight: bold;">git</span> push origin name_of_new_branch</pre></div></div>

<p>Ref. <a href="http://www.kernel.org/pub/software/scm/git/docs/git-stash.html"><code>git stash</code></a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://grx.no/kb/2010/04/23/git-start-a-new-branch-after-making-changes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Exclude several files or directories from tar</title>
		<link>http://grx.no/kb/2009/08/09/exclude-several-files-or-directories-from-tar/</link>
		<comments>http://grx.no/kb/2009/08/09/exclude-several-files-or-directories-from-tar/#comments</comments>
		<pubDate>Sun, 09 Aug 2009 14:08:34 +0000</pubDate>
		<dc:creator>hgrimelid</dc:creator>
				<category><![CDATA[Shell]]></category>
		<category><![CDATA[exclude]]></category>
		<category><![CDATA[gzip]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[tar]]></category>

		<guid isPermaLink="false">http://grx.no/kb/?p=172</guid>
		<description><![CDATA[It&#8217;s very useful to be able to exclude certain files or directories when using tar. Here&#8217;s how I did in Leopard: tar czvf FILENAME.tgz --exclude=&#123;.svn,wiki*,static&#125; FILES_OR_DIRS_TO_TAR]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s very useful to be able to exclude certain files or directories when using tar. Here&#8217;s how I did in Leopard:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">tar</span> czvf FILENAME.tgz <span style="color: #660033;">--exclude</span>=<span style="color: #7a0874; font-weight: bold;">&#123;</span>.svn,wiki<span style="color: #000000; font-weight: bold;">*</span>,static<span style="color: #7a0874; font-weight: bold;">&#125;</span> FILES_OR_DIRS_TO_TAR</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://grx.no/kb/2009/08/09/exclude-several-files-or-directories-from-tar/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Make SSHKeychain work in Leopard</title>
		<link>http://grx.no/kb/2009/06/22/make-sshkeychain-work-in-leopard/</link>
		<comments>http://grx.no/kb/2009/06/22/make-sshkeychain-work-in-leopard/#comments</comments>
		<pubDate>Mon, 22 Jun 2009 08:43:03 +0000</pubDate>
		<dc:creator>hgrimelid</dc:creator>
				<category><![CDATA[Shell]]></category>
		<category><![CDATA[leopard]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[mac os]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[sshkeychain]]></category>

		<guid isPermaLink="false">http://grx.no/kb/?p=164</guid>
		<description><![CDATA[Here&#8217;s how I set up SSHKeychain on my Mac: Modify the package content as described Add stuff to .bashrc/.profile Add keys to SSHKeychain: Preferences > SSH Keys Check Manage (and modify) global environment variables (this probably has no effect, ref 2.)]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s how I set up <a href="http://www.sshkeychain.org/">SSHKeychain</a> on my Mac:</p>
<ol>
<li><a href="http://samj.net/2008/06/sshkeychain-082-post-install-problem-on.html">Modify the package content as described<br />
</a></li>
<li><a href="http://sportsdaft.blogspot.com/2008/04/getting-sshkeychain-to-work-on-leopard.html">Add stuff to .bashrc/.profile</a></li>
<li>Add keys to SSHKeychain: Preferences > SSH Keys</li>
<li>Check Manage (and modify) global environment variables (this probably has no effect, ref 2.)</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://grx.no/kb/2009/06/22/make-sshkeychain-work-in-leopard/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Open Finder for current directory from command line</title>
		<link>http://grx.no/kb/2009/01/09/open-finder-for-current-directory-from-command-line/</link>
		<comments>http://grx.no/kb/2009/01/09/open-finder-for-current-directory-from-command-line/#comments</comments>
		<pubDate>Fri, 09 Jan 2009 07:41:22 +0000</pubDate>
		<dc:creator>hgrimelid</dc:creator>
				<category><![CDATA[Shell]]></category>
		<category><![CDATA[cli]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[mac os]]></category>

		<guid isPermaLink="false">http://grx.no/kb/?p=91</guid>
		<description><![CDATA[I just learned how to open a Finder window directly from the command line. open . Yes, it&#8217;s actually that easy, and the open command is quite handy some times. This is from the open man page. The open command opens a file (or a directory or URL), just as if you had double-clicked the [...]]]></description>
			<content:encoded><![CDATA[<p>I just learned how to open a Finder window directly from the command line.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">open .</pre></div></div>

<p>Yes, it&#8217;s actually that easy, and the <em>open</em> command is quite handy some times. This is from the <em>open</em> man page.</p>
<blockquote><p>
The open command opens a file (or a directory or URL), just as if you had double-clicked the<br />
     file&#8217;s icon. If no application name is specified, the default application as determined via<br />
     LaunchServices is used to open the specified files.</p></blockquote>
<p>This means that you can actually open anything from the command line with the <em>open</em> command. Go ahead and try it out!</p>
]]></content:encoded>
			<wfw:commentRss>http://grx.no/kb/2009/01/09/open-finder-for-current-directory-from-command-line/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Bash shell prompt colors</title>
		<link>http://grx.no/kb/2008/08/08/bash-shell-prompt-colors/</link>
		<comments>http://grx.no/kb/2008/08/08/bash-shell-prompt-colors/#comments</comments>
		<pubDate>Thu, 07 Aug 2008 22:25:57 +0000</pubDate>
		<dc:creator>hgrimelid</dc:creator>
				<category><![CDATA[Shell]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[colors]]></category>
		<category><![CDATA[prompt]]></category>

		<guid isPermaLink="false">http://grx.no/kb/?p=29</guid>
		<description><![CDATA[Here are the colors available for use in the bash shell prompt: Black 01;30 Blue 01;34 Brown 01;33 Cyan 01;36 Green 01;32 Red 01;31 Pink 01;35 Yellow 01;33 This is my shell prompt: PS1='\[\033[01;32m\]\u@\h \[\033[01;35m\]\W \$ \[\033[00m\]' Which produces output on the form user@computer DIRECTORY $. I use different colors for different computers/users.]]></description>
			<content:encoded><![CDATA[<p>Here are the colors available for use in the bash shell prompt:</p>
<table>
<tr>
<td>Black  </td>
<td>01;30</tr>
<tr>
<td>Blue   </td>
<td>01;34</tr>
<tr>
<td>Brown  </td>
<td>01;33</tr>
<tr>
<td>Cyan   </td>
<td>01;36</tr>
<tr>
<td>Green  </td>
<td>01;32</tr>
<tr>
<td>Red	   </td>
<td>01;31</tr>
<tr>
<td>Pink   </td>
<td>01;35</tr>
<tr>
<td>Yellow </td>
<td>01;33</tr>
</table>
<p>This is my shell prompt:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">PS1</span>=<span style="color: #ff0000;">'\[\033[01;32m\]\u@\h \[\033[01;35m\]\W \$ \[\033[00m\]'</span></pre></div></div>

<p>Which produces output on the form <em>user@computer DIRECTORY $</em>. I use different colors for different computers/users. </p>
]]></content:encoded>
			<wfw:commentRss>http://grx.no/kb/2008/08/08/bash-shell-prompt-colors/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Root partition free space</title>
		<link>http://grx.no/kb/2008/05/17/root-partition-free-space/</link>
		<comments>http://grx.no/kb/2008/05/17/root-partition-free-space/#comments</comments>
		<pubDate>Sat, 17 May 2008 17:21:15 +0000</pubDate>
		<dc:creator>hgrimelid</dc:creator>
				<category><![CDATA[Shell]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[cli]]></category>

		<guid isPermaLink="false">http://k.grx.no/?p=16</guid>
		<description><![CDATA[du -xh --max-depth=1 /]]></description>
			<content:encoded><![CDATA[
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">du</span> <span style="color: #660033;">-xh</span> <span style="color: #660033;">--max-depth</span>=<span style="color: #000000;">1</span>  <span style="color: #000000; font-weight: bold;">/</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://grx.no/kb/2008/05/17/root-partition-free-space/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>On using find</title>
		<link>http://grx.no/kb/2008/05/15/on-using-find/</link>
		<comments>http://grx.no/kb/2008/05/15/on-using-find/#comments</comments>
		<pubDate>Thu, 15 May 2008 10:49:24 +0000</pubDate>
		<dc:creator>hgrimelid</dc:creator>
				<category><![CDATA[Shell]]></category>
		<category><![CDATA[cli]]></category>
		<category><![CDATA[find]]></category>
		<category><![CDATA[search]]></category>
		<category><![CDATA[searching]]></category>
		<category><![CDATA[xargs]]></category>

		<guid isPermaLink="false">http://k.grx.no/?p=14</guid>
		<description><![CDATA[find is an extremely powerful command. In order to leave the directory matching *DIRECTORY* out from your search for .txt-files: find . -path '*DIRECTORY*' -prune -o -iname '*.txt' -print If you&#8217;re using xargs together with find and xargs complains about file names with spaces, use: find . YOURFINDOPTIONSHERE -print0 &#124; xargs -0 rm -rf Finding [...]]]></description>
			<content:encoded><![CDATA[<p><code>find</code> is an extremely powerful command. In order to leave the directory matching <code>*DIRECTORY*</code> out from your search for <code>.txt</code>-files:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">find</span> . <span style="color: #660033;">-path</span> <span style="color: #ff0000;">'*DIRECTORY*'</span> <span style="color: #660033;">-prune</span> <span style="color: #660033;">-o</span> <span style="color: #660033;">-iname</span> <span style="color: #ff0000;">'*.txt'</span> <span style="color: #660033;">-print</span></pre></div></div>

<p>If you&#8217;re using <code>xargs</code> together with <code>find</code> and <code>xargs</code> complains about file names with spaces, use:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">find</span> . YOURFINDOPTIONSHERE <span style="color: #660033;">-print0</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">xargs</span> <span style="color: #660033;">-0</span> <span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-rf</span></pre></div></div>

<p>Finding files larger than a certain limit:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">find</span> . <span style="color: #660033;">-size</span> +200M <span style="color: #660033;">-print0</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">xargs</span> <span style="color: #660033;">-0</span> <span style="color: #c20cb9; font-weight: bold;">ls</span> <span style="color: #660033;">-lh</span></pre></div></div>

<p>Deleting the complementary files:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">find</span> . <span style="color: #000000; font-weight: bold;">!</span> <span style="color: #660033;">-name</span> <span style="color: #ff0000;">&quot;*.mp3&quot;</span> <span style="color: #660033;">-delete</span></pre></div></div>

<p>Courtesy of <a href="http://hskaar.com/">HÃ¥kon</a>.</p>
<p>Please note that these commands pertains to the <em>BSD find</em> as on Mac OS 10.5.</p>
<p>UPDATE 20080517: Looking for file size<br />
UPDATE 20080602: Added deleting complement</p>
]]></content:encoded>
			<wfw:commentRss>http://grx.no/kb/2008/05/15/on-using-find/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>grep through several files</title>
		<link>http://grx.no/kb/2008/04/10/grep-through-several-files/</link>
		<comments>http://grx.no/kb/2008/04/10/grep-through-several-files/#comments</comments>
		<pubDate>Thu, 10 Apr 2008 08:13:05 +0000</pubDate>
		<dc:creator>hgrimelid</dc:creator>
				<category><![CDATA[Shell]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[grep]]></category>
		<category><![CDATA[search]]></category>

		<guid isPermaLink="false">http://k.grx.no/?p=3</guid>
		<description><![CDATA[By adding option -H to the grep command, the filename will be output together with the matching line: grep -i -H TEXT_TO_SEARCH_FOR -i turns on ignore case.]]></description>
			<content:encoded><![CDATA[<p>By adding option <em>-H</em> to the grep command, the filename will be output together with the matching line:</p>
<pre language="bash">
grep -i -H TEXT_TO_SEARCH_FOR
</pre>
<p><em>-i</em> turns on <i>ignore case</i>.</p>
]]></content:encoded>
			<wfw:commentRss>http://grx.no/kb/2008/04/10/grep-through-several-files/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

