<?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>controlc.de &#187; bash</title>
	<atom:link href="http://controlc.de/tag/bash/feed/" rel="self" type="application/rss+xml" />
	<link>http://controlc.de</link>
	<description>mehr als nur ein Notizblock</description>
	<lastBuildDate>Fri, 13 Jan 2012 18:37:18 +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>bash &#124; Abgestürzte ssh-Sitzungen beenden</title>
		<link>http://controlc.de/2011/09/20/bash-abgesturzte-ssh-sitzungen-beenden/</link>
		<comments>http://controlc.de/2011/09/20/bash-abgesturzte-ssh-sitzungen-beenden/#comments</comments>
		<pubDate>Tue, 20 Sep 2011 12:21:40 +0000</pubDate>
		<dc:creator>controlc.de</dc:creator>
				<category><![CDATA[debian]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[session]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[terminal]]></category>

		<guid isPermaLink="false">http://controlc.de/?p=2044</guid>
		<description><![CDATA[Ab und an reagieren SSH-Sessions nicht mehr und damit ist das komplette Terminal blockiert. Das liegt meist daran, das die Netzwerkverbindung unterbrochen wurde — sei es auf Grund von Netzwerkfehlern oder weil das Notebook in den Energiesparmodus gegangen ist. In solchen Fällen habe ich immer das Terminal-Fenster geschlossen, was ich ziemlich nervig fand (Stichwort: Fensteranordnung [...]]]></description>
			<content:encoded><![CDATA[	<p style="text-align: center;"><a href="http://controlc.de/wp-content/uploads/2011/08/Absturz-SSH-Verkehrsschild.png" class="floatbox" rev="group:2044 caption:`Absturz SSH Verkehrsschild`"><img class="aligncenter size-medium wp-image-2060" title="Absturz SSH Verkehrsschild" src="http://controlc.de/wp-content/uploads/2011/08/Absturz-SSH-Verkehrsschild-300x281.png" alt="" width="270" height="253" /></a></p>
	<p>Ab und an reagieren SSH-Sessions nicht mehr und damit ist das komplette Terminal blockiert. Das liegt meist daran, das die Netzwerkverbindung unterbrochen wurde — sei es auf Grund von Netzwerkfehlern oder weil das Notebook in den Energiesparmodus gegangen ist. In solchen Fällen habe ich immer das Terminal-Fenster geschlossen, was ich ziemlich nervig fand (Stichwort: Fensteranordnung im <a href="http://www.iterm2.com">iTerm</a>). Irgendwann habe ich die <a href="http://blog.jozjan.net/2008/01/close-your-frozen-ssh-session.html" target="_blank">Lösung</a> gefunden, die ich Euch nicht vorenthalten möchte. Wenn man im Terminal-Fenster die Tasten [ENTER] [TILDE] und [PUNKT] der Reihe nach eingibt, wird die abgestürzte SSH-Session beendet und das Terminal freigegeben:</p>
	
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">↩~.</pre></div></div>

	<p>Da ich mir das nicht merken kann bzw. mir die Tastenkombination zu kompliziert ist, habe ich damit einfach <a href="http://www.ergonis.com/products/typinator/">Typinator</a> »missbraucht«</p>
	<p><a href="http://controlc.de/wp-content/uploads/2011/09/Typinator-SSH-session-abort.png" class="floatbox" rev="group:2044 caption:`Typinator - SSH session abort`"><img class="aligncenter size-medium wp-image-2067" title="Typinator - SSH session abort" src="http://controlc.de/wp-content/uploads/2011/09/Typinator-SSH-session-abort-265x300.png" alt="" width="265" height="300" /></a>So ist es mir möglich mit der Tastenkombination »XXX« jede hängende SSH-Session zu beenden.
</p>
]]></content:encoded>
			<wfw:commentRss>http://controlc.de/2011/09/20/bash-abgesturzte-ssh-sitzungen-beenden/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>mac &#124; OSX Lion und die aktuellste BASH-Shell</title>
		<link>http://controlc.de/2011/08/04/mac-osx-lion-und-die-aktuellste-bash-shell/</link>
		<comments>http://controlc.de/2011/08/04/mac-osx-lion-und-die-aktuellste-bash-shell/#comments</comments>
		<pubDate>Thu, 04 Aug 2011 08:45:06 +0000</pubDate>
		<dc:creator>controlc.de</dc:creator>
				<category><![CDATA[mac]]></category>
		<category><![CDATA[10.7]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[lion]]></category>
		<category><![CDATA[shell]]></category>

		<guid isPermaLink="false">http://controlc.de/?p=2052</guid>
		<description><![CDATA[Man sollte meinen, das Apple mit der Herausgabe eines neuen Betriebssystems nach knappen zwei Jahren auch alle Komponenten auf den aktuellsten Stand bringt — zumindest in Bezug auf die Standard-Shell Bash trifft das auf jeden Fall nicht zu. Auch in OS X Lion 10.7 ist die mitgelieferte Bash-Version die 3.2.48 — die letzte Überarbeitung der [...]]]></description>
			<content:encoded><![CDATA[	<p><a href="http://controlc.de/wp-content/uploads/2011/02/Bash.png" class="floatbox" rev="group:2052 caption:`Bash`"><img class="aligncenter size-full wp-image-2010" title="Bash" src="http://controlc.de/wp-content/uploads/2011/02/Bash.png" alt="" width="462" height="344" /></a>Man sollte meinen, das Apple mit der Herausgabe eines neuen Betriebssystems nach knappen zwei Jahren auch alle Komponenten auf den aktuellsten Stand bringt — zumindest in Bezug auf die Standard-Shell <a href="http://tiswww.case.edu/php/chet/bash/bashtop.html" target="_blank">Bash</a> trifft das auf jeden Fall nicht zu. Auch in <a href="http://www.apple.com/de/macosx/" target="_blank">OS X Lion 10.7</a> ist die mitgelieferte Bash-Version die 3.2.48 — die letzte Überarbeitung der Version 3. Meine frühere Beschreibung zur <a href="http://controlc.de/2011/02/06/mac-osx-und-die-shell/">Installation von BASH-Version 4</a> trifft immer noch zu — die zur Zeit aktuellste Version von Bash ist die 4.2.
</p>
]]></content:encoded>
			<wfw:commentRss>http://controlc.de/2011/08/04/mac-osx-lion-und-die-aktuellste-bash-shell/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>mac &#124; OSX und die Shell</title>
		<link>http://controlc.de/2011/02/06/mac-osx-und-die-shell/</link>
		<comments>http://controlc.de/2011/02/06/mac-osx-und-die-shell/#comments</comments>
		<pubDate>Sun, 06 Feb 2011 19:36:37 +0000</pubDate>
		<dc:creator>controlc.de</dc:creator>
				<category><![CDATA[mac]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[macosx]]></category>

		<guid isPermaLink="false">http://controlc.de/?p=2009</guid>
		<description><![CDATA[In MacOSX ist die Standardshell Bash — leider in der ca. fast schon zwei Jahre alten Version 3.2.48. Das wird jetzt nicht jeden stören, da nicht jeder auf der Kommandozeile arbeitet. Wer aber, wie ich, ab und an ein Shell-Script erstellt, wird vielleicht schon mal mit der »neuesten« Version 4.1 geliebäugelt haben. Hervorzuheben sind There [...]]]></description>
			<content:encoded><![CDATA[	<p><a href="http://controlc.de/wp-content/uploads/2011/02/Bash.png" class="floatbox" rev="group:2009 caption:`Bash`"><img class="aligncenter size-full wp-image-2010" title="Bash" src="http://controlc.de/wp-content/uploads/2011/02/Bash.png" alt="" width="462" height="344" /></a>In MacOSX ist die Standardshell Bash — leider in der ca. fast schon zwei Jahre alten Version 3.2.48. Das wird jetzt nicht jeden stören, da nicht jeder auf der Kommandozeile arbeitet. Wer aber, wie ich, ab und an ein Shell-Script erstellt, wird vielleicht schon mal mit der »neuesten« Version 4.1 geliebäugelt haben. Hervorzuheben sind</p>
	<blockquote>
	<pre>There is a new `autocd' option that, when enabled, causes bash to attempt
to `cd' to a directory name that is supplied as the first word of a
simple command.
</pre>
	<pre>There is a new shell option: `globstar'.  When enabled, the globbing code
treats `**' specially -- it matches all directories (and files within
them, when appropriate) recursively.
</pre>
	<pre>There is a new shell option: `dirspell'.  When enabled, the filename
completion code performs spelling correction on directory names during
completion.
</pre>
	<pre>Brace expansion now allows zero-padding of expanded numeric values and
will add the proper number of zeroes to make sure all values contain the
same number of digits.
</pre>
	<pre>There is a new &amp;&gt;&gt; redirection operator, which appends the standard output
and standard error to the named file.
</pre>
	<pre>The parser now understands `|&amp;' as a synonym for `2&gt;&amp;1 |', which redirects
the standard error for a command through a pipe.
</pre>
	</blockquote>
	<p>Alle neuen Features aufzuzählen würde zu viel Zeit rauben, deswegen sei auf die <a href="http://tiswww.case.edu/php/chet/bash/NEWS">Liste des Bash-Maintainers</a> verwiesen.</p>
	<p>Wie man diese Version in OSX installiert werde ich hier zeigen.</p>
	<p><span id="more-2009"></span>Es gibt verschiedene Wege um Bash 4 in OSX zu installieren: Neben <a href="http://www.macports.org/">MacPorts</a>, <a href="http://mxcl.github.com/homebrew/">Homebrew</a> möchte ich hier zeigen, wie man sich Bash 4 aus dem Quellcode selbst kompiliert. Das klingt erst mal kompliziert, ist es aber gar nicht. Man muss sich nur Xcode aus den Developer Tools installieren — die hat man auf den Installation-CDs von OSX oder kann sie auch direkt von <a href="http://developer.apple.com/">Apple</a> herunterladen.</p>
	<p>Nun lädt man sich das aktuelle Quellcode-Archiv vom <a href="http://ftp.gnu.org/gnu/bash/">FTP-Server</a> herunter</p>
	
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">curl http:<span style="color: #000000; font-weight: bold;">//</span>ftp.gnu.org<span style="color: #000000; font-weight: bold;">/</span>gnu<span style="color: #000000; font-weight: bold;">/</span>bash<span style="color: #000000; font-weight: bold;">/</span>bash-<span style="color: #000000;">4.1</span>.tar.gz <span style="color: #660033;">-o</span> bash-<span style="color: #000000;">4.1</span>.tar.gz</pre></div></div>

	<p>und entpackt diesen auf seiner Festplatte. Ich nehme dazu den Pfad <em>~/usr/local/src</em>.</p>
	
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">tar</span> xvzf bash-<span style="color: #000000;">4.1</span>.tar.gz <span style="color: #660033;">-C</span> ~<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>src<span style="color: #000000; font-weight: bold;">/</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #7a0874; font-weight: bold;">cd</span> ~<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>src<span style="color: #000000; font-weight: bold;">/</span>bash-<span style="color: #000000;">4.1</span></pre></div></div>

	<p>anschliessend</p>
	
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">.<span style="color: #000000; font-weight: bold;">/</span>configure <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #c20cb9; font-weight: bold;">install</span></pre></div></div>

	<p>die neue Bash wird dann nach <em>/usr/local/bin</em> installiert.</p>
	<p>Nun muss die neue zusätzliche Shell dem System bekannt gemacht werden. Das geschieht mit dem Befehl</p>
	
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">bash</span> <span style="color: #660033;">-c</span> <span style="color: #ff0000;">&quot;echo /usr/local/bin/bash &gt;&gt; /private/etc/shells&quot;</span></pre></div></div>

	<p>in der Datei <em>/etc/shells</em></p>
	<p><a href="http://controlc.de/wp-content/uploads/2011/02/shells.png" class="floatbox" rev="group:2009 caption:`/etc/shells`"><img class="aligncenter size-medium wp-image-2015" title="/etc/shells" src="http://controlc.de/wp-content/uploads/2011/02/shells-300x204.png" alt="" width="300" height="204" /></a>Jetzt kann jeder Benutzer für sich die neue Shell als Standardshell definieren.</p>
	<p><a href="http://controlc.de/wp-content/uploads/2011/02/chsh-1.png" class="floatbox" rev="group:2009 caption:`chsh 1`"><img class="aligncenter size-full wp-image-2017" title="chsh 1" src="http://controlc.de/wp-content/uploads/2011/02/chsh-1.png" alt="" width="208" height="53" /></a></p>
	<p>In dem darauffolgendem Editor-Fenster ändert man die Zeile Shell von <em>/bin/bash</em></p>
	<p><a href="http://controlc.de/wp-content/uploads/2011/02/chsh-2.png" class="floatbox" rev="group:2009"></a><a href="http://controlc.de/wp-content/uploads/2011/02/chsh-2.png" class="floatbox" rev="group:2009 caption:`chsh 2`"><img class="aligncenter size-full wp-image-2020" title="chsh 2" src="http://controlc.de/wp-content/uploads/2011/02/chsh-2.png" alt="" width="304" height="172" /></a></p>
	<p>zu <em>/usr/local/bin/bash</em></p>
	<p><a href="http://controlc.de/wp-content/uploads/2011/02/chsh-3.png" class="floatbox" rev="group:2009 caption:`chsh 3`"><img class="aligncenter size-full wp-image-2021" title="chsh 3" src="http://controlc.de/wp-content/uploads/2011/02/chsh-3.png" alt="" width="303" height="172" /></a></p>
	<p>Nach einem Neustart der Terminal-Session hat man nun Bash 4 als Shell.</p>
	<p>Einige Beispiele für die neuen Features findet man bei <a href="http://concisionandconcinnity.blogspot.com/2009/03/upgrade-bash-to-40-in-mac-os-x.html">Ian McCracken</a>, wo auch die englischsprachige Anleitung für die Installation von Bash 4 zu finden ist.
</p>
]]></content:encoded>
			<wfw:commentRss>http://controlc.de/2011/02/06/mac-osx-und-die-shell/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>bash &#124; History aufwerten</title>
		<link>http://controlc.de/2010/03/14/bash-history-aufwerten/</link>
		<comments>http://controlc.de/2010/03/14/bash-history-aufwerten/#comments</comments>
		<pubDate>Sun, 14 Mar 2010 09:00:52 +0000</pubDate>
		<dc:creator>controlc.de</dc:creator>
				<category><![CDATA[allgemeine IT]]></category>
		<category><![CDATA[apple]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[.bash_profile]]></category>
		<category><![CDATA[.profile]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[command line]]></category>
		<category><![CDATA[history]]></category>
		<category><![CDATA[how to]]></category>
		<category><![CDATA[session]]></category>
		<category><![CDATA[terminal]]></category>

		<guid isPermaLink="false">http://controlc.de/?p=614</guid>
		<description><![CDATA[Wenn man öfter auf der Kommandozeile arbeitet lernt man die History-Funktion zu schätzen. Hier eine lose Aufstellung einiger Möglichkeiten, wie man die History-Funktion noch weiter aufbohren und an seine Bedürfnisse anpassen kann. Update: Aufgrund von weiteren Recherchen und des Kommentars auf macfidelity habe ich diesen Artikel noch einmal überarbeitet und weitere Informationen hinzugefügt. Einleitung Die [...]]]></description>
			<content:encoded><![CDATA[	<p><a href="http://controlc.de/wp-content/uploads/2009/06/bash-history-terminal.png" class="floatbox" rev="group:614 caption:`bash-history-terminal`"><img class="aligncenter size-full wp-image-1581" title="bash-history-terminal" src="http://controlc.de/wp-content/uploads/2009/06/bash-history-terminal.png" alt="" width="200" height="178" /></a></p>
	<p>Wenn man öfter auf der Kommandozeile arbeitet lernt man die History-Funktion zu schätzen. Hier eine lose Aufstellung einiger Möglichkeiten, wie man die History-Funktion noch weiter aufbohren und an seine Bedürfnisse anpassen kann.<br />
<strong>Update:</strong> <em>Aufgrund von weiteren Recherchen und des <a href="http://macfidelity.de/2010/03/11/randnotiz-tweaking-terminal-history/#comment-14527">Kommentars</a> auf <a href="http://macfidelity.de">macfidelity</a> habe ich diesen Artikel noch einmal überarbeitet und weitere Informationen hinzugefügt.</em><br />
<span id="more-614"></span></p>
	<h3>Einleitung</h3>
	<p>Die History ist eine eingebaute Funktion in dem Befehlsinterpreter <a href="http://www.gnu.org/software/bash/">bash</a> — der Standardshell inzwischen vieler *nixe bzw. *BSDs, so auch von Mac OS X. Die History hat eingebaute Befehle, die man wunderbar im <a href="http://www.gnu.org/software/bash/manual/bashref.html#Bash-Builtins">Handbuch von Bash</a> nachlesen kann, oder in Kürze erklärt bei <a href="http://macfidelity.de/2010/03/11/randnotiz-tweaking-terminal-history/">macfidelity</a> findet. Das Grundverhalten der History kann man, wie auch ziemlich vieler anderer Funktionen, in den Profil-Dateien der bash definieren. Dazu möchte ich auf den Artikel <a href="http://controlc.de/2010/03/12/bash-shell-einrichten/">Bash-Shell einrichten</a> verweisen.</p>
	<h3>History von mehreren parallel laufenden Terminalsessions sichern</h3>
	<p>Oft genug hat man mehrere Terminalsessions zu einem Host offen um sich z.B. in der einen Session das Logfile anzuschauen, während man in anderen Session einen Befehl ausführt. Beim Beenden der Session wird aber nur eine History gespeichert. Um immer hinzuzufügen führt man folgenden Befehl aus</p>
	
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">shopt</span> <span style="color: #660033;">-s</span> histappend</pre></div></div>

	<h3>History sofort speichern</h3>
	<p>Die History einer Sesion wird immer erst beim Beenden einer Session in die Datei .bash_history gespeichert. Um bei parallelen Terminalsessions auf die Befehle zuzugreifen, die gerade erst in einer anderen Session getätigt wurden, kann man mit der Umgebungsvariablen</p>
	
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">PROMPT_COMMAND</span>=<span style="color: #ff0000;">'history -a'</span></pre></div></div>

	<p>die Shell dazu zwingen bei jedem Generieren eines neuen Prompts (als einer Befehlseingabezeile) die History zu schreiben.</p>
	<h3>History mit Timestamp</h3>
	<p>Um im Historyfile sich pro Befehl auch einen Timestamp hinzufügen zu lassen gibt man folgendes ein:</p>
	
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">HISTTIMEFORMAT</span>=<span style="color: #ff0000;">'%a %T '</span></pre></div></div>

	<p>Die Variablen dafür kann man sich von <a href="http://php.net/manual/de/function.strftime.php">strftime</a> abschauen.</p>
	<h3>Größe des History-Speichers in der Datei</h3>
	<p>Wie viele Zeile die History-Datei speichern kann weiß ich zwar nicht genau (ich denke aber das es 500 Zeilen sind), aber vergrößern kann man ihn mit</p>
	
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">HISTFILESIZE</span>=<span style="color: #000000;">1000</span></pre></div></div>

	<p>oder aber man schaltet gleich die Größenbeschränkung aus:</p>
	
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">unset</span> HISTFILESIZE</pre></div></div>

	<p>Mit der Variable</p>
	
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">HISTSIZE</span>=<span style="color: #000000;">500</span></pre></div></div>

	<p>kann man definieren, wie viele Zeilen maximal beim Beenden einer Terminalsession in die History-Datei geschrieben werden.</p>
	<h3>Ignorieren von Befehlen</h3>
	<p>Alle eingegebenen Befehle werden in die History gespeichert. Dieses Verhalten kann man etwas einschränken, indem man Befehle, welche mit einem Leerzeichen anfangen nicht in die History aufnehmen läßt</p>
	
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">HISTCONTROL</span>=ignorespace</pre></div></div>

	<p>So kann man auch bewußt Befehle nicht in die History schreiben lassen, wenn man z.B. statt »<em>ls«</em> einfach «<em> ls</em>« eingibt.</p>
	<h3>Keine Duplikate in die History</h3>
	<p>Wie oben schon beschrieben werden alle Befehle in die History aufgenommen, auch die, die mehrfach eingegeben wurden. Möchte man das nicht</p>
	
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">HISTCONTROL</span>=ignoredups</pre></div></div>

	<p>Möchte man weder Duplikate, noch die mit einem Leerzeichen am Anfang, so gibt man folgendes ein</p>
	
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">HISTCONTROL</span>=ignoreboth</pre></div></div>

	<h3>Spezielle Zeilen von der History ausschließen</h3>
	<p>Wenn die Variable HISTCONTROL nicht gesetzt ist, kann man auch selbst entscheiden, welche Zeilen nicht in die History aufgenommen werden sollen. Dies geschieht durch die Variable HISTIGNORE, welche mit Doppelpunkten getrennt</p>
	
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">HISTIGNORE</span>=<span style="color: #ff0000;">'cat*:cd*:vi*:ls*'</span></pre></div></div>

	<p>Damit werden alle Zeilen, die mit <em>cat</em>, <em>cd</em> oder<em> vi</em> oder<em> ls</em> beginnen, nicht in der History gespeichert. Es bietet sich auch an hier alle selbst definierten Aliase anzugeben. Da theoretisch hier mit regulären Ausdrücken gearbeitet werden kann, stehen der Phantasie alle Möglichkeiten offen.</p>
	<h3>Fragen über Fragen</h3>
	<p><em>Kennt Ihr noch mehr Befehle um die History zu »pimpen«? <span style="text-decoration: line-through;">Ich kann mich daran erinnern, das es einen Befehl gab, mit dem man automatisch gleich nach jedem Return den Befehl in die History schreiben lassen kann — aber wie hies der nur?</span></em>
</p>
]]></content:encoded>
			<wfw:commentRss>http://controlc.de/2010/03/14/bash-history-aufwerten/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>bash &#124; Shell einrichten</title>
		<link>http://controlc.de/2010/03/12/bash-shell-einrichten/</link>
		<comments>http://controlc.de/2010/03/12/bash-shell-einrichten/#comments</comments>
		<pubDate>Fri, 12 Mar 2010 13:08:54 +0000</pubDate>
		<dc:creator>controlc.de</dc:creator>
				<category><![CDATA[allgemeine IT]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[.bash_profile]]></category>
		<category><![CDATA[.profile]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[command line]]></category>
		<category><![CDATA[farben]]></category>
		<category><![CDATA[history]]></category>
		<category><![CDATA[inputrc]]></category>
		<category><![CDATA[ls colors]]></category>
		<category><![CDATA[macosx]]></category>
		<category><![CDATA[prompt]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[terminal]]></category>

		<guid isPermaLink="false">http://controlc.de/?p=912</guid>
		<description><![CDATA[Gerade bei OSX kommt man ja meist drumherum mit der Kommandozeile zu arbeiten — dabei kann man in der Shell einiges schneller bzw. einfacher machen und um gewisse Einstellungen von OSX (wie zum Beispiel hier und hier beschrieben) zu ändern kommt man nicht umher das Terminal zu öffnen. Vorgeplänkel Wie man im Finder oder in [...]]]></description>
			<content:encoded><![CDATA[	<p><a href="http://controlc.de/wp-content/uploads/2009/11/Bash.png" class="floatbox" rev="group:912 caption:`Bash`"><img class="aligncenter size-medium wp-image-1063" title="Bash" src="http://controlc.de/wp-content/uploads/2009/11/Bash-300x232.png" alt="" width="300" height="232" /></a></p>
	<p>Gerade bei OSX kommt man ja meist drumherum mit der Kommandozeile zu arbeiten — dabei kann man in der Shell einiges schneller bzw. einfacher machen und um gewisse Einstellungen von OSX (wie zum Beispiel <a href="http://controlc.de/2009/06/11/mac-apple-mail-optimieren/">hier</a> und <a href="http://controlc.de/2009/10/30/mac-apple-mail-das-kopieren-von-email-adressen/">hier</a> beschrieben) zu ändern kommt man nicht umher das Terminal zu öffnen.<span id="more-912"></span></p>
	<h3>Vorgeplänkel</h3>
	<p>Wie man im Finder oder in jedem anderen Programm zuerst seine Benutzeroberfläche einrichtet, so macht man das auch in der Kommandozeile. Nur wird das hier nicht über eine Preference File gemacht sondern über (in OSX) versteckte Systemdateien. Da OSX diese Schreiben bzw. Erstellen dieser Dateien zum Teil für den normalen Benutzer verboten hat, muss man daran denken, das man sich <em>root</em>–Rechte holt. Das geht einmal mit dem Account <em>root </em>(Zur Aktivierung des <em>root</em>–Accounts verweise ich auf <a href="http://support.apple.com/kb/HT1528">Apple</a>), zu dem ich mit dem Shell-Befehl</p>
	
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">su</span> -</pre></div></div>

	<p>oder</p>
	
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #660033;">-s</span></pre></div></div>

	<p>wechsle. Oder aber zukünftig jedem Befehl ein</p>
	
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span></pre></div></div>

	<p>voransetze.</p>
	<p>Für die Individualisierung der Shell sind verschiedene Dateien und Verzeichnisse wichtig. Zuerst wird zwischen den Benutzereinstellungen und den Einstellungen für den ganzen Rechner unterschieden. Die Benutzereinstellungen liegen im Userverzeichnis, also <em>/Users/BENUTZERNAME</em> (Ausnahme hier ist der Benutzer<em> root</em>, der sein Homeverzeichnis in <em>/root</em> findet) und die Systemeinstellungen im Verzeichnis <em>/etc</em>. Wie die Namen schon sagen, sind die ersteren nur für den angemeldeten Benutzer gültig, die Systemeinstellungen für jeden Benutzer.</p>
	<p>Individuelle Anpassungen kann man einmal für das Tastaturmapping machen — hier sind die Dateien <em>/etc/inputrc </em>bzw. <em>~/.inputrc</em> verantwortlich und für  das Aussehen bzw. das definieren von Umgebungsvariablen — dafür sind die Dateien <em>/etc/profile</em> und <em>/etc/bash.bashrc</em> bzw. <em>~/.bash_profile, ~/.profile, ~/.bashrc</em> und <em>~/bash_login</em>. Eine gute Zusammenfassung der Reihenfolge der Abarbeitung der Dateien findet man <a href="http://stefaanlippens.net/bashrc_and_others">hier</a>. Der Einfachheit halber benutze ich in diesem Artikel die Datei <em>profile</em>.</p>
	<h3>Farben für den tristen Alltag</h3>
	<p>Mit Farben kann man sich die Shell übersichtlicher machen. Dazu hat <a href="http://macfidelity.de/2009/10/09/mac-snow-leopard-terminal-einrichten/">fidel</a> schon mal was geschrieben. Definiert werden diese in der Profil-Datei. Man kann den Prompt bearbeiten (Farbe und Aussehen).  Standard ist folgendes Aussehen</p>
	<p><a href="http://controlc.de/wp-content/uploads/2010/03/default-shell-look.png" class="floatbox" rev="group:912 caption:`default shell look`"><img class="aligncenter size-medium wp-image-1547" title="default shell look" src="http://controlc.de/wp-content/uploads/2010/03/default-shell-look-300x132.png" alt="" width="300" height="132" /></a>In meinem Fall brauche ich die Angabe des Rechner-Namens nicht und ein nettes Gelb kann auch nicht schaden</p>
	
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">PS1</span>=<span style="color: #ff0000;">&quot;\[\e[33;1;40m\][\u] \w&gt;\[\e[0m\] &quot;</span></pre></div></div>

	<p><a href="http://controlc.de/wp-content/uploads/2010/03/modified-ps1-prompt.png" class="floatbox" rev="group:912 caption:`modified ps1 prompt`"><img class="aligncenter size-medium wp-image-1548" title="modified ps1 prompt" src="http://controlc.de/wp-content/uploads/2010/03/modified-ps1-prompt-300x136.png" alt="" width="300" height="136" /></a>Das Gleiche kann man auch für den Prompt definieren, wenn man mit <em>sudo</em> sich temporäre <em>root</em>–Rechte gibt. In meinem Fall möchte ich gelbe Schrift auf einem rotem Untergrund.</p>
	
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">SUDO_PS1</span>=<span style="color: #ff0000;">&quot;\[\e[33;1;41m\][\u] \w&gt;\[\e[0m\] &quot;</span></pre></div></div>

	<p><a href="http://controlc.de/wp-content/uploads/2010/03/modified-sudo_ps1-prompt.png" class="floatbox" rev="group:912 caption:`modified sudo_ps1 prompt`"><img class="aligncenter size-medium wp-image-1549" title="modified sudo_ps1 prompt" src="http://controlc.de/wp-content/uploads/2010/03/modified-sudo_ps1-prompt-300x136.png" alt="" width="300" height="136" /></a>Das sieht jetzt alles recht kryptisch aus, was daran liegt, das die Programmierung des Prompts in Escape-Sequenzen erfolgen muss. Wenn man etwas tiefer in die Materie einsteigen will, seinen ganz persönlichen Prompt bauen möchte oder schlicht einfach verstehen will, was hier gemacht wird, dem sein <a href="http://blog.pimpmyshell.de/2007/12/10/pimp-your-prompt/">pimp my shell</a> ans Herz gelegt. Es gibt dann auch noch Informationen von <a href="http://www.ibm.com/developerworks/linux/library/l-tip-prompt/">IBM</a> und <a href="http://networking.ringofsaturn.com/Unix/Bash-prompts.php">Ring of saturn</a>.</p>
	<p>Ein oft benutzter Befehl in der Kommandozeile lautet <em>ls</em> zum Anzeigen eine Verzeichnisinhalts. Um die verschiedenen Inhalte wie Verzeichnisse, Dateien, Symlinks und Co. auseinanderzuhalten ist eine farbige Darstellung sehr nützlich. Dies kann man entwerder durch das Aufrufen des Befehls <em>ls</em> mit dem Schalter <em>–G</em> erreichen, oder aber, wenn man die Farben selber definieren will, mit folgenden Umgebungsvariablen</p>
	
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">CLICOLOR</span>=<span style="color: #000000;">1</span>
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">LSCOLORS</span>=dxfxcxbxegedabagacad</pre></div></div>

	<p>Die Bedeutung der jeweiligen Optionen kann man sich <a href="http://linux-sxs.org/housekeeping/lscolors.html">hier</a> anschauen. Für ganz Faule gibt es einen <a href="http://geoff.greer.fm/lscolors/">Generator</a>.</p>
	<p>Um dem Befehl <em>grep</em> etwas Farbe zu geben, muss folgende Umgebungsvariable gesetzt werden</p>
	
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">GREP_OPTIONS</span>=<span style="color: #ff0000;">'--color=auto'</span> <span style="color: #007800;">GREP_COLOR</span>=<span style="color: #ff0000;">'1;32'</span></pre></div></div>

	<h3><a href="http://controlc.de/wp-content/uploads/2010/03/GREP_OPTIONS.png" class="floatbox" rev="group:912 caption:`GREP_OPTIONS`"><img class="aligncenter size-medium wp-image-1556" title="GREP_OPTIONS" src="http://controlc.de/wp-content/uploads/2010/03/GREP_OPTIONS-300x148.png" alt="" width="300" height="148" /></a>Einfacher Zugriff auf die History</h3>
	<p>Ich hatte hier schon mal was über die <a href="http://controlc.de/2009/06/10/bash-history-aufwerten/">Einstellungen der bash history</a> geschrieben. Die Einstellungen dort werden in der Profil-Datei gemacht. Wie in den Kommentaren hinzugefügt benutze ich folgendes Tastaturmapping in <em>/etc/inputrc</em></p>
	
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #ff0000;">&quot;e[5~&quot;</span>: history-search-backward
<span style="color: #ff0000;">&quot;e[6~&quot;</span>: history-search-forward</pre></div></div>

	<p>Damit kann ich mit den Tasten Bild rauf/Page up bzw. Bild runter/Page down durch die History scrollen. Das funktioniert sogar basierend auf dem, was schon auf der Kommandozeile steht. Gebe ich zum Beispiel <em>less</em> ein, dann werden mir mit den genannten Tasten nur die History-Einträge angezeigt, die mit dieser Buchstabenfolge anfangen.</p>
	<p>Damit die history gleich geschrieben wird und nicht erst beim Beenden der shell session kann in der Profil-Datei mit</p>
	
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># Append commands to the history every time a prompt is shown,</span>
<span style="color: #666666; font-style: italic;"># instead of after closing the session.</span>
<span style="color: #007800;">PROMPT_COMMAND</span>=<span style="color: #ff0000;">'history -a'</span></pre></div></div>

	<p>erzwungen werden, dass mit jedem Erzeugen eines neuen Prompts die history geschrieben wird.</p>
	<h3>Leichteres Admin-Leben mit Aliasen</h3>
	<p>Standardmäßig wird dem normalen Benutzer beim Aufrufen von ls die Ansicht auf dotfiles verwehrt. Mit dem Eintrag</p>
	
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #ff0000;">&quot;ls=ls -a&quot;</span></pre></div></div>

	<p>wird das korrigiert. Ansonsten kann man hier Programmaufrufen feste Parameter mitgeben und auch langen Befehlszeilen Kürzel vergeben.</p>
	<h3>Zusätzliches</h3>
	<p>Möchte man zusätzliche Pfad als Standardpfad einzurichten, damit man beim Aufrufen nicht den gesamten Pfad angeben muss, dann gibt man diesen wie folgt an:</p>
	
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">PATH</span>=<span style="color: #007800;">$PATH</span>:<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>src<span style="color: #000000; font-weight: bold;">/</span>bin</pre></div></div>

	<p>Wenn man Änderungen an den Profil-Dateien macht, dann werden diese Änderungen erst gültig, wenn die Profil-Datei erneut eingelesen wird. Das erreicht man entweder mit dem Öffnen einer neuen Terminal-Session oder aber mit dem Befehl</p>
	
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">source</span> ~<span style="color: #000000; font-weight: bold;">/</span>.profile</pre></div></div>

	<h3>Fragen über Fragen</h3>
	<p><em>Wie sieht Eure Individualisierung der Kommandzeile aus? Welche Möglichkeiten habe ich vergessen zu erklären? Kanntet Ihr schon alle Möglichkeiten?</em>
</p>
]]></content:encoded>
			<wfw:commentRss>http://controlc.de/2010/03/12/bash-shell-einrichten/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>bash &#124; Backups mit tar</title>
		<link>http://controlc.de/2009/11/22/bash-backups-mit-tar/</link>
		<comments>http://controlc.de/2009/11/22/bash-backups-mit-tar/#comments</comments>
		<pubDate>Sun, 22 Nov 2009 11:40:58 +0000</pubDate>
		<dc:creator>controlc.de</dc:creator>
				<category><![CDATA[allgemeine IT]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[command line]]></category>
		<category><![CDATA[how to]]></category>
		<category><![CDATA[tar]]></category>

		<guid isPermaLink="false">http://controlc.de/?p=1041</guid>
		<description><![CDATA[In einem älteren Artikel habe ich mich schon mal damit beschäftigt, wie man in *nix-basierten Betriebssystemen leicht Backups anlegen kann. Da der Bedarf bei mir wieder mal akuter wurde, haber ich mich wieder mal damit beschäftigt und möchte hier erklären, wie man was machen kann. Backup von bestimmten Dateien Häufiger möchte man, wenn man mal [...]]]></description>
			<content:encoded><![CDATA[	<p><a href="http://controlc.de/wp-content/uploads/2009/11/Bash.png" class="floatbox" rev="group:1041 caption:`Bash`"><img class="aligncenter size-medium wp-image-1063" title="Bash" src="http://controlc.de/wp-content/uploads/2009/11/Bash-300x232.png" alt="Bash" width="300" height="232" /></a>In einem <a href="http://controlc.de/2009/05/20/bash-schnelles-backup-anlegen/">älteren Artikel</a> habe ich mich schon mal damit beschäftigt, wie man in *nix-basierten Betriebssystemen leicht Backups anlegen kann. Da der Bedarf bei mir wieder mal akuter wurde, haber ich mich wieder mal damit beschäftigt und möchte hier erklären, wie man was machen kann.</p>
	<h4><span id="more-1041"></span>Backup von bestimmten Dateien</h4>
	<p>Häufiger möchte man, wenn man mal schnell etwas in einer Config-Datei etwas ändert, davon fix ein Backup anlegen. Klassisch habe ich das meist schnell mit</p>
	
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">cp</span> DATEI.conf DATEI.conf.orig</pre></div></div>

	<p>gelöst. Was aber passiert, wenn man dann später nochmal was ändern will respektive ein neues Backup angelegt werden soll?! Wie man dieses Problem erschlägt, habe ich schon mal in <a href="http://controlc.de/2009/05/20/bash-schnelles-backup-anlegen/">diesem Artikel</a> erklärt — das war aber nur ein Schnellschuß. Das Problem dabei ist nämlich, das man ja jeweils die alten Backups nochmal mitsichert und dadurch die Backups immer größer werden. Dies kann man durch einen Exclude-Parameter von tar auschließen. Der Befehl um in einem Verzeichnis alle Dateien zu sichern lautet also</p>
	
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">tar</span> <span style="color: #660033;">-cz</span> <span style="color: #660033;">--no-recursion</span> <span style="color: #660033;">--exclude</span>=backup-<span style="color: #000000; font-weight: bold;">*</span>.tar.gz <span style="color: #660033;">-f</span> backup-$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">date</span> +<span style="color: #000000; font-weight: bold;">%</span>F-<span style="color: #000000; font-weight: bold;">%</span>H-<span style="color: #000000; font-weight: bold;">%</span>M<span style="color: #7a0874; font-weight: bold;">&#41;</span>.tar.gz <span style="color: #000000; font-weight: bold;">*</span></pre></div></div>

	<h4>Backup von ganzen Pfaden inkl. der Unterverzeichnisse</h4>
	<p>In einigen Fällen will man nicht nur die Dateien in einem Verzeichnis sichern sondern lieber gleich den Inhalt gesamte Verzeichnis inklusive aller Unterverzeichnisse</p>
	
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">tar</span> <span style="color: #660033;">-cz</span> <span style="color: #660033;">--exclude</span>=backup-<span style="color: #000000; font-weight: bold;">*</span>.tar.gz <span style="color: #660033;">-f</span> backup-$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">date</span> +<span style="color: #000000; font-weight: bold;">%</span>F-<span style="color: #000000; font-weight: bold;">%</span>H-<span style="color: #000000; font-weight: bold;">%</span>M<span style="color: #7a0874; font-weight: bold;">&#41;</span>.tar.gz .</pre></div></div>

	<h4>Backup von Dateien bzw. Pfaden, die im gesamten System verteilt sind</h4>
	<p>Und schließlich hat man den Fall, das man alle wichtigen Dateien eines Systems sichern will, die aber über das gesamte System verteilt sind. Dies erreicht man mit einer Include-Datei</p>
	
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">tar</span> cvzf <span style="color: #000000; font-weight: bold;">/</span>backup-$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">date</span> +<span style="color: #000000; font-weight: bold;">%</span>F-<span style="color: #000000; font-weight: bold;">%</span>T<span style="color: #7a0874; font-weight: bold;">&#41;</span>.tar.gz <span style="color: #660033;">-T</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>backup-include-dir.conf</pre></div></div>

	<p>wobei man in die Datei <em>/etc/backup-include-dir.conf</em> alle Pfade bzw. alle Dateien reinschreibt, die gesichert werden sollen. Wichtig ist dabei nur: Pro Datei/Pfad jeweils eine Zeile.</p>
	<p>Und denkt daran: Solche Befehlszeilen eignen sich wunderbar dazu als alias definiert zu werden, damit man schnell drauf zugreifen kann, wenn man es mal braucht.
</p>
]]></content:encoded>
			<wfw:commentRss>http://controlc.de/2009/11/22/bash-backups-mit-tar/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>bash &#124; schnelles Backup anlegen</title>
		<link>http://controlc.de/2009/05/20/bash-schnelles-backup-anlegen/</link>
		<comments>http://controlc.de/2009/05/20/bash-schnelles-backup-anlegen/#comments</comments>
		<pubDate>Wed, 20 May 2009 09:27:35 +0000</pubDate>
		<dc:creator>controlc.de</dc:creator>
				<category><![CDATA[allgemeine IT]]></category>
		<category><![CDATA[apple]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[how to]]></category>
		<category><![CDATA[tar]]></category>

		<guid isPermaLink="false">http://controlc.de/?p=420</guid>
		<description><![CDATA[Bei Jann habe ich Folgendes unter dem Stichwort In der Shell schnell mal alle Dateien im Verzeichnis nach *.bak sichern gelesen: Kurznotiz, gilt für Mac / Linux / Unix / (bei Windows hilft nur “format c:” ) Oft muss ich in einem Ordner schnell mal alle Dateien sichern als Backup da ich sie im nächsten [...]]]></description>
			<content:encoded><![CDATA[	<p>Bei <a href="http://adminday.de">Jann</a> habe ich Folgendes unter dem Stichwort <a href="http://adminday.de/tutorials-und-tipps/in-der-shell-schnell-mal-alle-dateien-im-verzeichnis-nach-bak-sichern/">In der Shell schnell mal alle Dateien im Verzeichnis nach *.bak sichern</a> gelesen:</p>
	<blockquote><p>Kurznotiz, gilt für Mac / Linux / Unix / (bei Windows hilft nur “format c:” <img class="wp-smiley" src="http://adminday.de/wp-includes/images/smilies/icon_wink.gif" alt=";)" /> )<br />
Oft muss ich in einem Ordner schnell mal alle Dateien sichern als Backup da ich sie im nächsten Moment überschreibe.  Um nicht den ganzen übergeordneten Ordner gleich komplett sichern zu müssen sondern nur die Dateien im aktuellen Ordner <span style="text-decoration: underline;">ohne Unterverzeichnisse</span> zu sichern habe ich folgenden befehl:<br />
for i in *.*; do cp $i $i.bak ;done<br />
Alle Dateien im Ordner werden dann von xyz.txt nach xyz.txt.bak kopiert, wer anstelle des kopieren die Daten verschieben will ersetzt im script einfach “cp” mit “mv”  Wer in einem Verzeichnis nur bestimmte Dateitypen z.B. *.html sichern mag macht dies dann so:<br />
for i in *.html; do cp $i $i.bak ; done<br />
somit werden an alle *.html Dateien im Ordner nach *.html.bak gesichert  Das gleiche geht mit jedem beliebigen Dateityp ^^</p></blockquote>
	<p>Lange habe ich drüber nachgedacht, da ich den Ansatz etwas zu kompliziert finde und da ich gerade in dem Buch <a href="http://www.oreilly.de/catalog/bash3ger/index.html">Einführung in die BASH</a> lese und mal schauen wollte, was davon bei mir hängen geblieben ist, habe ich folgendes ausprobiert:</p>
	
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">tar</span> <span style="color: #660033;">-cz</span> <span style="color: #660033;">--no-recursion</span> <span style="color: #660033;">-f</span> backup-$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">date</span> +<span style="color: #000000; font-weight: bold;">%</span>F-<span style="color: #000000; font-weight: bold;">%</span>H-<span style="color: #000000; font-weight: bold;">%</span>M<span style="color: #7a0874; font-weight: bold;">&#41;</span>.tar.gz <span style="color: #000000; font-weight: bold;">*</span></pre></div></div>

	<p>Das Ganze als Alias definiert mit Übergabe der Dateiextension sieht dann so aus:</p>
	
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">archive</span>=<span style="color: #ff0000;">'tar -cz --no-recursion -f backup-$(date +%F-%H-%M).tar.gz $1'</span></pre></div></div>

	<p>Damit kann man später schnell mit</p>
	
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">archive <span style="color: #000000; font-weight: bold;">*</span>.html</pre></div></div>

	<p>schnell alle HTML-Files eines Verzeichnisses sichern und weiß gleich von wann die Sicherung ist.
</p>
]]></content:encoded>
			<wfw:commentRss>http://controlc.de/2009/05/20/bash-schnelles-backup-anlegen/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>debian &#124; Zertifikaterstellungsskript</title>
		<link>http://controlc.de/2009/05/11/zertifikaterstellungsskript/</link>
		<comments>http://controlc.de/2009/05/11/zertifikaterstellungsskript/#comments</comments>
		<pubDate>Mon, 11 May 2009 10:20:07 +0000</pubDate>
		<dc:creator>controlc.de</dc:creator>
				<category><![CDATA[allgemeine IT]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[how to]]></category>
		<category><![CDATA[openssl]]></category>
		<category><![CDATA[skript]]></category>
		<category><![CDATA[zertifikate]]></category>

		<guid isPermaLink="false">http://controlc.de/?p=126</guid>
		<description><![CDATA[Wenn man mit https seine Webseiten bzw. deren Kommunikation oder aber das Senden von Emails über SSL absichert, dann kommt man nicht drumherum ab und an ein neues Zertifikat auszustellen. Da ich das nicht jeden Tag mache und mich dann immer wieder totsuche, habe ich mir ein kleines Skript geschrieben: #! /bin/sh cd /etc/ssl openssl [...]]]></description>
			<content:encoded><![CDATA[	<p>Wenn man mit https seine Webseiten bzw. deren Kommunikation oder aber das Senden von Emails über SSL absichert, dann kommt man nicht drumherum ab und an ein neues Zertifikat auszustellen. Da ich das nicht jeden Tag mache und mich dann immer wieder totsuche, habe ich mir ein kleines Skript geschrieben:</p>
	
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#! /bin/sh</span>
<span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>ssl
openssl req <span style="color: #660033;">-new</span> <span style="color: #660033;">-nodes</span> <span style="color: #660033;">-out</span> <span style="color: #007800;">$1</span>-req.pem <span style="color: #660033;">-keyout</span> private<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">$1</span>-key.pem <span style="color: #660033;">-config</span> .<span style="color: #000000; font-weight: bold;">/</span>openssl.cnf
openssl ca <span style="color: #660033;">-out</span> <span style="color: #007800;">$1</span>.pem <span style="color: #660033;">-config</span> .<span style="color: #000000; font-weight: bold;">/</span>openssl.cnf <span style="color: #660033;">-infiles</span> <span style="color: #007800;">$1</span>-req.pem
openssl x509 <span style="color: #660033;">-in</span> <span style="color: #007800;">$1</span>.pem <span style="color: #660033;">-out</span> <span style="color: #007800;">$1</span>-cert.pem</pre></div></div>

	<p>Update: Damit ich das Skript systemweit verwenden kann lege ich es nach <code>/usr/local/bin als create_certs</code> und mache es mit dem Befehl</p>
	
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">chmod</span> g+x <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>create_certs</pre></div></div>

	<p>ausführbar.</p>
	<p>Update 2: Warum hat mir eigentlich keiner gesagt, das die temporäre Datei $1.pem, die in der dritten openssl-Zeile benötigt wird um aus dem Request ein fertiges Zertifikat zu machen, natürlich am Ende des Skripts gelöscht werden kann? Ein</p>
	
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #007800;">$1</span>.pem</pre></div></div>

	<p>in der letzten Zeile sollte reichen.
</p>
]]></content:encoded>
			<wfw:commentRss>http://controlc.de/2009/05/11/zertifikaterstellungsskript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>debian &#124; Standardeditor festlegen</title>
		<link>http://controlc.de/2009/03/18/debian-standardeditor-festlegen/</link>
		<comments>http://controlc.de/2009/03/18/debian-standardeditor-festlegen/#comments</comments>
		<pubDate>Wed, 18 Mar 2009 07:43:15 +0000</pubDate>
		<dc:creator>controlc.de</dc:creator>
				<category><![CDATA[allgemeine IT]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[editor]]></category>

		<guid isPermaLink="false">http://controlc.de/2009/03/18/debian-standardeditor-festlegen/</guid>
		<description><![CDATA[Ich mag den mc-Editor — deswegen habe ich diesen als Standardeditor in der bash festgelegt export EDITOR=/usr/bin/mcedit Eine Alternative in Debian ist: update-alternatives --config editor Update: Auf meinem neuen vServer ist nun Debian Lenny installiert und hier hatte ich das Problem, das im mc (Midnight Commander) immer nano als Standardeditor geöffnet wurde. Keine Ahnung, warum [...]]]></description>
			<content:encoded><![CDATA[	<p>Ich mag den mc-Editor — deswegen habe ich diesen als Standardeditor in der bash festgelegt</p>
	
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">EDITOR</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>mcedit</pre></div></div>

	<p>Eine Alternative in Debian ist:</p>
	
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">update-alternatives <span style="color: #660033;">--config</span> editor</pre></div></div>

	<p><em>Update: Auf meinem neuen vServer ist nun Debian Lenny installiert und hier hatte ich das Problem, das im <a href="http://de.wikipedia.org/wiki/Midnight_Commander">mc</a> (Midnight Commander) immer nano als Standardeditor geöffnet wurde. Keine Ahnung, warum nano. Im Menü des mc unter Options/Configuration muß die Option »use internal edit« angehakt sein, dann klappt es auch innerhalb des mc´s mit mcedit.</em>
</p>
]]></content:encoded>
			<wfw:commentRss>http://controlc.de/2009/03/18/debian-standardeditor-festlegen/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

