<?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>Abraxas &#187; Shell</title>
	<atom:link href="http://www.effinger.org/blog/tag/shell/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.effinger.org/blog</link>
	<description>a personal knowledge base</description>
	<lastBuildDate>Sun, 06 Jun 2010 17:41:45 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>HTML Entities von der Shell aus in Text umwandeln</title>
		<link>http://www.effinger.org/blog/2009/12/30/html-entities-von-der-shell-aus-in-text-umwandeln/</link>
		<comments>http://www.effinger.org/blog/2009/12/30/html-entities-von-der-shell-aus-in-text-umwandeln/#comments</comments>
		<pubDate>Wed, 30 Dec 2009 10:59:17 +0000</pubDate>
		<dc:creator>Markus Effinger</dc:creator>
				<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[Shell]]></category>

		<guid isPermaLink="false">http://www.effinger.org/blog/?p=829</guid>
		<description><![CDATA[<p>Bislang hatte ich noch kein Pogramm gesehen, bei dem man auf der Kommandozeile einfach HTML Entitäten, wie &#38;gt; oder &#38;amp; in den normalen Zeichensatz zurückkonvertieren kann. Sicher, es gibt dafür eine PHP-Funktion und bestimmt auch eine entsprechende Perl-Funktion, aber warum nicht etwas einfacheres nutzen..</p>

sudo apt-get install recode
recode HTML.. &#60; file.html &#62; file.txt

<p>Recode kann übrigens noch [...]]]></description>
			<content:encoded><![CDATA[<p>Bislang hatte ich noch kein Pogramm gesehen, bei dem man auf der Kommandozeile einfach HTML Entitäten, wie &amp;gt; oder &amp;amp; in den normalen Zeichensatz zurückkonvertieren kann. Sicher, es gibt dafür eine PHP-Funktion und bestimmt auch eine entsprechende Perl-Funktion, aber warum nicht etwas einfacheres nutzen..</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;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> recode
recode HTML.. <span style="color: #000000; font-weight: bold;">&lt;</span> file.html <span style="color: #000000; font-weight: bold;">&gt;</span> file.txt</pre></div></div>

<p>Recode kann übrigens noch mehr, z.B. die Zeilenumbrüche vom Linux-Format zu Windows konvertieren. Eine <a href="http://www.linux.co.uk/docs/center/manual/debian-reference/debian-tips/nifty-little-commands-to-remember/convert-a-text-file-with-recode">kleine Beispielsammlung gibt es bei linux.co.uk</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.effinger.org/blog/2009/12/30/html-entities-von-der-shell-aus-in-text-umwandeln/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>.bash_profile und .bashrc</title>
		<link>http://www.effinger.org/blog/2008/12/03/bash_profile-und-bashrc/</link>
		<comments>http://www.effinger.org/blog/2008/12/03/bash_profile-und-bashrc/#comments</comments>
		<pubDate>Tue, 02 Dec 2008 23:39:02 +0000</pubDate>
		<dc:creator>Markus Effinger</dc:creator>
				<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[Shell]]></category>

		<guid isPermaLink="false">http://www.effinger.org/blog/?p=275</guid>
		<description><![CDATA[<p>Ich war erstaunt darüber, dass ich beim Login via SSH und über das Gnome-Terminal einen unterschiedlichen Prompt angezeigt bekam. Wie sich nach dem Lesen des Artikels von Josh Staiger herausstellte, war die Ursache dafür, dass die Bash beim Login auf der Konsole (beispielsweise über ein physisches Terminal oder mit SSH und Telnet) die .bash_profile ausführt [...]]]></description>
			<content:encoded><![CDATA[<p>Ich war erstaunt darüber, dass ich beim Login via SSH und über das Gnome-Terminal einen unterschiedlichen Prompt angezeigt bekam. Wie sich nach dem Lesen des <a href="http://joshstaiger.org/archives/2005/07/bash_profile_vs.html">Artikels von Josh Staiger</a> herausstellte, war die Ursache dafür, dass die Bash beim Login auf der Konsole (beispielsweise über ein physisches Terminal oder mit SSH und Telnet) die .bash_profile ausführt und beim Aufruf eines Terminals über einen Windowmanager wie Gnome oder KDE die .bashrc ausführt. Damit nun bei jedem Login &#8211; egal ob von Konsole oder in Gnome &#8211; alles identisch ist (Shell-Funktionen, Aliase, Prompt usw.) habe ich meine .bash_profile so angepasst, dass sie auf die .bashrc verweist:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># When using a console, either physically at the machine or</span>
<span style="color: #666666; font-style: italic;"># using ssh, .bash_profile is executed.</span>
<span style="color: #666666; font-style: italic;"># I want the same functions and aliases available as if logged in</span>
<span style="color: #666666; font-style: italic;"># from a terminal within a windowing system such as KDE</span>
<span style="color: #666666; font-style: italic;"># therefore we link to .bashrc if it is available</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-f</span> ~<span style="color: #000000; font-weight: bold;">/</span>.bashrc <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
   <span style="color: #7a0874; font-weight: bold;">source</span> ~<span style="color: #000000; font-weight: bold;">/</span>.bashrc
<span style="color: #000000; font-weight: bold;">fi</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.effinger.org/blog/2008/12/03/bash_profile-und-bashrc/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Arbeitserleichterung durch .bashrc und .bash_aliases</title>
		<link>http://www.effinger.org/blog/2008/11/20/arbeitserleichterung-durch-bashrc-und-bash_aliases/</link>
		<comments>http://www.effinger.org/blog/2008/11/20/arbeitserleichterung-durch-bashrc-und-bash_aliases/#comments</comments>
		<pubDate>Thu, 20 Nov 2008 21:37:30 +0000</pubDate>
		<dc:creator>Markus Effinger</dc:creator>
				<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[Shell]]></category>

		<guid isPermaLink="false">http://www.effinger.org/blog/?p=195</guid>
		<description><![CDATA[<p>Eine derjenigen Dateien, die man auf jeden Fall an seine persönlichen Bedürfnisse anpassen sollte, ist die .bashrc. Diese Datei ermöglicht es unter anderem, den Prompt der Bash-Shell zu setzen und eigene Funktionen sowie Aliasnamen für häufig benutzte Befehle festzulegen. Meine bashrc sieht aktuell so aus und enthält Code-Schnipsel von John Lawrence, geekosphere.org und Isaac Schlueter:</p>

# [...]]]></description>
			<content:encoded><![CDATA[<p>Eine derjenigen Dateien, die man auf jeden Fall an seine persönlichen Bedürfnisse anpassen sollte, ist die .bashrc. Diese Datei ermöglicht es unter anderem, den <a href="http://www.kahless.de/?page_id=53">Prompt der Bash-Shell zu setzen</a> und eigene Funktionen sowie Aliasnamen für häufig benutzte Befehle festzulegen. Meine bashrc sieht aktuell so aus und enthält Code-Schnipsel von <a href="http://www.johnlawrence.net/code/?f=sfbashrc">John Lawrence</a>, <a href="http://geekosphere.org/401/pimp-my-server-bashrc-screenrc-nanorc-tuning/">geekosphere.org</a> und <a href="http://foohack.com/2008/05/steal-my-bash-profile/">Isaac Schlueter</a>:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># ~/.bashrc: executed by bash(1) for non-login shells.</span>
<span style="color: #666666; font-style: italic;"># see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)</span>
<span style="color: #666666; font-style: italic;"># for examples</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># If not running interactively, don't do anything</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-z</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$PS1</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #7a0874; font-weight: bold;">return</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># don't put duplicate lines in the history. See bash(1) for more options</span>
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">HISTCONTROL</span>=ignoredups
<span style="color: #666666; font-style: italic;"># ... and ignore same sucessive entries.</span>
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">HISTCONTROL</span>=ignoreboth
&nbsp;
<span style="color: #666666; font-style: italic;"># check the window size after each command and, if necessary,</span>
<span style="color: #666666; font-style: italic;"># update the values of LINES and COLUMNS.</span>
<span style="color: #7a0874; font-weight: bold;">shopt</span> <span style="color: #660033;">-s</span> checkwinsize
&nbsp;
<span style="color: #666666; font-style: italic;"># make less more friendly for non-text input files, see lesspipe(1)</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-x</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>lesspipe <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #7a0874; font-weight: bold;">eval</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$(SHELL=/bin/sh lesspipe)</span>&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># set variable identifying the chroot you work in (used in the prompt below)</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-z</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$debian_chroot</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-r</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>debian_chroot <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
    <span style="color: #007800;">debian_chroot</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>debian_chroot<span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> jobcount <span style="color: #7a0874; font-weight: bold;">&#123;</span>
	<span style="color: #7a0874; font-weight: bold;">jobs</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">wc</span> <span style="color: #660033;">-l</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">tr</span> <span style="color: #660033;">-d</span> <span style="color: #ff0000;">&quot; &quot;</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Color prompt</span>
bash_color_prompt<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
&nbsp;
	<span style="color: #7a0874; font-weight: bold;">local</span> <span style="color: #007800;">BLACK</span>=<span style="color: #ff0000;">&quot;\[\e[0;30m\]&quot;</span>
	<span style="color: #7a0874; font-weight: bold;">local</span> <span style="color: #007800;">BLUE</span>=<span style="color: #ff0000;">&quot;\[\e[0;34m\]&quot;</span>
	<span style="color: #7a0874; font-weight: bold;">local</span> <span style="color: #007800;">GREEN</span>=<span style="color: #ff0000;">&quot;\[\e[0;32m\]&quot;</span>
	<span style="color: #7a0874; font-weight: bold;">local</span> <span style="color: #007800;">CYAN</span>=<span style="color: #ff0000;">&quot;\[\e[0;36m\]&quot;</span>
	<span style="color: #7a0874; font-weight: bold;">local</span> <span style="color: #007800;">RED</span>=<span style="color: #ff0000;">&quot;\[\e[0;31m\]&quot;</span>
	<span style="color: #7a0874; font-weight: bold;">local</span> <span style="color: #007800;">PURPLE</span>=<span style="color: #ff0000;">&quot;\[\e[0;35m\]&quot;</span>
	<span style="color: #7a0874; font-weight: bold;">local</span> <span style="color: #007800;">BROWN</span>=<span style="color: #ff0000;">&quot;\[\e[0;33m\]&quot;</span>
	<span style="color: #7a0874; font-weight: bold;">local</span> <span style="color: #007800;">LIGHTGRAY</span>=<span style="color: #ff0000;">&quot;\[\e[0;37m\]&quot;</span>
	<span style="color: #7a0874; font-weight: bold;">local</span> <span style="color: #007800;">DARKGRAY</span>=<span style="color: #ff0000;">&quot;\[\e[1;30m\]&quot;</span>
	<span style="color: #7a0874; font-weight: bold;">local</span> <span style="color: #007800;">LIGHTBLUE</span>=<span style="color: #ff0000;">&quot;\[\e[1;34m\]&quot;</span>
	<span style="color: #7a0874; font-weight: bold;">local</span> <span style="color: #007800;">LIGHTGREEN</span>=<span style="color: #ff0000;">&quot;\[\e[1;32m\]&quot;</span>
	<span style="color: #7a0874; font-weight: bold;">local</span> <span style="color: #007800;">LIGHTCYAN</span>=<span style="color: #ff0000;">&quot;\[\e[1;36m\]&quot;</span>
	<span style="color: #7a0874; font-weight: bold;">local</span> <span style="color: #007800;">LIGHTRED</span>=<span style="color: #ff0000;">&quot;\[\e[1;31m\]&quot;</span>
	<span style="color: #7a0874; font-weight: bold;">local</span> <span style="color: #007800;">LIGHTPURPLE</span>=<span style="color: #ff0000;">&quot;\[\e[1;35m\]&quot;</span>
	<span style="color: #7a0874; font-weight: bold;">local</span> <span style="color: #007800;">YELLOW</span>=<span style="color: #ff0000;">&quot;\[\e[1;33m\]&quot;</span>
	<span style="color: #7a0874; font-weight: bold;">local</span> <span style="color: #007800;">WHITE</span>=<span style="color: #ff0000;">&quot;\[\e[1;37m\]&quot;</span>
	<span style="color: #666666; font-style: italic;"># No Color</span>
	<span style="color: #7a0874; font-weight: bold;">local</span> <span style="color: #007800;">NC</span>=<span style="color: #ff0000;">&quot;\[\e[0m\]&quot;</span>
	<span style="color: #7a0874; font-weight: bold;">local</span> <span style="color: #007800;">cur_tty</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span>tty <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;s/.*tty\(.*\)/\1/&quot;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
	<span style="color: #7a0874; font-weight: bold;">local</span> <span style="color: #007800;">loadavg</span>=<span style="color: #ff0000;">'$(uptime | sed -e &quot;s/.*load average: \(.*\...\), \(.*\...\), \(.*\...\)/\1/&quot; -e &quot;s/ //g&quot;)'</span>
&nbsp;
	<span style="color: #007800;">PS1</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">${LIGHTRED}</span>\u<span style="color: #007800;">${NC}</span>@<span style="color: #007800;">${LIGHTBLUE}</span>\h<span style="color: #007800;">${NC}</span>-<span style="color: #007800;">${GREEN}</span><span style="color: #007800;">$(date +&quot;%d.%m.%Y %H:%M:%S&quot;)</span><span style="color: #007800;">${NC}</span>:<span style="color: #007800;">${YELLOW}</span>\w<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #007800;">${BROWN}</span>[j:<span style="color: #780078;">`jobcount`</span>, t:<span style="color: #007800;">$cur_tty</span>, l:<span style="color: #007800;">$loadavg</span>]<span style="color: #007800;">${WHITE}</span><span style="color: #000099; font-weight: bold;">\n</span>\<span style="color: #000099; font-weight: bold;">\$</span> <span style="color: #007800;">${NC}</span>&quot;</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># set a fancy prompt (non-color, unless we know we &quot;want&quot; color)</span>
<span style="color: #000000; font-weight: bold;">case</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$TERM</span>&quot;</span> <span style="color: #000000; font-weight: bold;">in</span>
    xterm-color<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #007800;">color_prompt</span>=<span style="color: #c20cb9; font-weight: bold;">yes</span><span style="color: #000000; font-weight: bold;">;;</span>
<span style="color: #000000; font-weight: bold;">esac</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># uncomment for a colored prompt, if the terminal has the capability; turned</span>
<span style="color: #666666; font-style: italic;"># off by default to not distract the user: the focus in a terminal window</span>
<span style="color: #666666; font-style: italic;"># should be on the output of commands, not on the prompt</span>
<span style="color: #007800;">force_color_prompt</span>=<span style="color: #c20cb9; font-weight: bold;">yes</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$force_color_prompt</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-x</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>tput <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> tput setaf <span style="color: #000000;">1</span> <span style="color: #000000; font-weight: bold;">&gt;&amp;/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null; <span style="color: #000000; font-weight: bold;">then</span>
	<span style="color: #666666; font-style: italic;"># We have color support; assume it's compliant with Ecma-48</span>
	<span style="color: #666666; font-style: italic;"># (ISO/IEC-6429). (Lack of such support is extremely rare, and such</span>
	<span style="color: #666666; font-style: italic;"># a case would tend to support setf rather than setaf.)</span>
	<span style="color: #007800;">color_prompt</span>=<span style="color: #c20cb9; font-weight: bold;">yes</span>
    <span style="color: #000000; font-weight: bold;">else</span>
	<span style="color: #007800;">color_prompt</span>=
    <span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$color_prompt</span>&quot;</span> = <span style="color: #c20cb9; font-weight: bold;">yes</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
    <span style="color: #666666; font-style: italic;">#PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '</span>
	bash_color_prompt
<span style="color: #000000; font-weight: bold;">else</span>
    <span style="color: #007800;">PS1</span>=<span style="color: #ff0000;">'${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '</span>
<span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #7a0874; font-weight: bold;">unset</span> color_prompt force_color_prompt
&nbsp;
<span style="color: #666666; font-style: italic;"># If this is an xterm set the title to user@host:dir</span>
<span style="color: #000000; font-weight: bold;">case</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$TERM</span>&quot;</span> <span style="color: #000000; font-weight: bold;">in</span>
xterm<span style="color: #000000; font-weight: bold;">*|</span>rxvt<span style="color: #000000; font-weight: bold;">*</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
    <span style="color: #007800;">PROMPT_COMMAND</span>=<span style="color: #ff0000;">'echo -ne &quot;\033]0;${USER}@${HOSTNAME}: ${PWD/$HOME/~}\007&quot;'</span>
    <span style="color: #000000; font-weight: bold;">;;</span>
<span style="color: #000000; font-weight: bold;">*</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
    <span style="color: #000000; font-weight: bold;">;;</span>
<span style="color: #000000; font-weight: bold;">esac</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Alias definitions.</span>
<span style="color: #666666; font-style: italic;"># You may want to put all your additions into a separate file like</span>
<span style="color: #666666; font-style: italic;"># ~/.bash_aliases, instead of adding them here directly.</span>
<span style="color: #666666; font-style: italic;"># See /usr/share/doc/bash-doc/examples in the bash-doc package.</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-f</span> ~<span style="color: #000000; font-weight: bold;">/</span>.bash_aliases <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
    . ~<span style="color: #000000; font-weight: bold;">/</span>.bash_aliases
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># enable programmable completion features (you don't need to enable</span>
<span style="color: #666666; font-style: italic;"># this, if it's already enabled in /etc/bash.bashrc and /etc/profile</span>
<span style="color: #666666; font-style: italic;"># sources /etc/bash.bashrc).</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-f</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>bash_completion <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
    . <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>bash_completion
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#Sicherstellen, dass Sprache deutsch und Zeitzone für Deutschland passt</span>
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">LC_CTYPE</span>=de_DE.UTF-<span style="color: #000000;">8</span>
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">LC_ALL</span>=<span style="color: #ff0000;">&quot;&quot;</span>
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">LANG</span>=<span style="color: #007800;">$LC_CTYPE</span>
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">LANGUAGE</span>=<span style="color: #007800;">$LANG</span>
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">TZ</span>=Europe<span style="color: #000000; font-weight: bold;">/</span>Berlin
&nbsp;
<span style="color: #666666; font-style: italic;">################## Start functions from http://www.perlmonks.org/?viewmode=public;node_id=359168 ###################################</span>
<span style="color: #666666; font-style: italic;"># path-manipulating shell functions</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> lspath <span style="color: #7a0874; font-weight: bold;">&#123;</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$PATH</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">tr</span> <span style="color: #ff0000;">':'</span> <span style="color: #ff0000;">'\n'</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> makepath <span style="color: #7a0874; font-weight: bold;">&#123;</span>
    <span style="color: #7a0874; font-weight: bold;">unset</span> NEW_PATH
    <span style="color: #000000; font-weight: bold;">while</span> <span style="color: #c20cb9; font-weight: bold;">read</span> PATHEL; <span style="color: #000000; font-weight: bold;">do</span>
        <span style="color: #007800;">NEW_PATH</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$NEW_PATH</span>:<span style="color: #007800;">$PATHEL</span>&quot;</span>
    <span style="color: #000000; font-weight: bold;">done</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #800000;">${NEW_PATH#:}</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> uniqpath <span style="color: #7a0874; font-weight: bold;">&#123;</span>
    <span style="color: #007800;">PATH</span>=<span style="color: #000000; font-weight: bold;">`</span>lspath <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{seen[$0]++; if (seen[$0]==1){print}}'</span> <span style="color: #000000; font-weight: bold;">|</span> makepath<span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> cleanpath <span style="color: #7a0874; font-weight: bold;">&#123;</span>
    uniqpath
    <span style="color: #007800;">PATH</span>=<span style="color: #000000; font-weight: bold;">`</span>lspath <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">'s|\/$||'</span> <span style="color: #660033;">-ne</span> <span style="color: #ff0000;">'/./p'</span> <span style="color: #000000; font-weight: bold;">|</span> makepath<span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> addpath <span style="color: #7a0874; font-weight: bold;">&#123;</span>
    <span style="color: #007800;">PATH</span>=$<span style="color: #000000;">1</span>:<span style="color: #007800;">$PATH</span>
    cleanpath
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> appendpath <span style="color: #7a0874; font-weight: bold;">&#123;</span>
    <span style="color: #007800;">PATH</span>=<span style="color: #007800;">$PATH</span>:$<span style="color: #000000;">1</span>
    cleanpath
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> delpath <span style="color: #7a0874; font-weight: bold;">&#123;</span>
    <span style="color: #007800;">PATH</span>=<span style="color: #000000; font-weight: bold;">`</span>lspath <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-v</span> <span style="color: #ff0000;">&quot;^$1<span style="color: #000099; font-weight: bold;">\$</span>&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> makepath<span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> editpath <span style="color: #7a0874; font-weight: bold;">&#123;</span>
    <span style="color: #007800;">TEMP</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">mktemp</span> <span style="color: #ff0000;">&quot;/tmp/<span style="color: #007800;">${FUNCNAME}</span>.XXXXXX&quot;</span><span style="color: #000000; font-weight: bold;">`</span>
    lspath <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #007800;">$TEMP</span>
    <span style="color: #800000;">${EDITOR:-vi}</span> <span style="color: #007800;">$TEMP</span>
    <span style="color: #007800;">PATH</span>=<span style="color: #000000; font-weight: bold;">`</span>makepath <span style="color: #000000; font-weight: bold;">&lt;</span> <span style="color: #007800;">$TEMP</span><span style="color: #000000; font-weight: bold;">`</span>
    <span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-f</span> <span style="color: #007800;">$TEMP</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
<span style="color: #666666; font-style: italic;">################## End functions from http://www.perlmonks.org/?viewmode=public;node_id=359168 ###################################</span>
&nbsp;
<span style="color: #666666; font-style: italic;">################## Begin functions from http://www.johnlawrence.net/code/?f=sfbashrc ###################################</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#compare files using comm (requires perl) - http://www.shell-fu.org/lister.php?id=186</span>
compare<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#123;</span>
  <span style="color: #c20cb9; font-weight: bold;">comm</span> $<span style="color: #000000;">1</span> $<span style="color: #000000;">2</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">perl</span> <span style="color: #660033;">-pe</span> <span style="color: #ff0000;">'s/^/1: /g;s/1: \t/2: /g;s/2: \t/A: /g;'</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sort</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># overwrite a file with zeroes - http://www.shell-fu.org/lister.php?id=94</span>
zero<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">case</span> <span style="color: #ff0000;">&quot;$1&quot;</span> <span style="color: #000000; font-weight: bold;">in</span>
    <span style="color: #ff0000;">&quot;&quot;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>     <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Usage: zero &quot;</span>
            <span style="color: #7a0874; font-weight: bold;">return</span> -<span style="color: #000000;">1</span>;
  <span style="color: #000000; font-weight: bold;">esac</span>
  <span style="color: #007800;">filesize</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">wc</span> <span style="color: #660033;">-c</span>  <span style="color: #ff0000;">&quot;$1&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{print $1}'</span><span style="color: #000000; font-weight: bold;">`</span>
  <span style="color: #c20cb9; font-weight: bold;">dd</span> <span style="color: #007800;"><span style="color: #000000; font-weight: bold;">if</span></span>=<span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>zero <span style="color: #007800;">of</span>=$<span style="color: #000000;">1</span> <span style="color: #007800;">count</span>=<span style="color: #007800;">$filesize</span> <span style="color: #007800;">bs</span>=<span style="color: #000000;">1</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># create a terminal calculator - http://www.shell-fu.org/lister.php?id=216</span>
calc<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#123;</span> <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${1}</span>&quot;</span><span style="color: #000000; font-weight: bold;">|</span><span style="color: #c20cb9; font-weight: bold;">bc</span> -l; <span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># copy and paste from the command line - http://www.shell-fu.org/lister.php?id=177</span>
ccopy<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#123;</span> <span style="color: #c20cb9; font-weight: bold;">cp</span> $<span style="color: #000000;">1</span> <span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>ccopy.$<span style="color: #000000;">1</span>; <span style="color: #7a0874; font-weight: bold;">&#125;</span>
<span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">cpaste</span>=<span style="color: #ff0000;">&quot;ls /tmp/ccopy* | sed 's|[^\.]*.\.||' | xargs -I % mv /tmp/ccopy.% ./%&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># bash function to decompress archives - http://www.shell-fu.org/lister.php?id=375</span>
extract <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-f</span> $<span style="color: #000000;">1</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> ; <span style="color: #000000; font-weight: bold;">then</span>
        <span style="color: #000000; font-weight: bold;">case</span> $<span style="color: #000000;">1</span> <span style="color: #000000; font-weight: bold;">in</span>
            <span style="color: #000000; font-weight: bold;">*</span>.tar.bz2<span style="color: #7a0874; font-weight: bold;">&#41;</span>   <span style="color: #c20cb9; font-weight: bold;">tar</span> xvjf $<span style="color: #000000;">1</span>        <span style="color: #000000; font-weight: bold;">;;</span>
            <span style="color: #000000; font-weight: bold;">*</span>.tar.gz<span style="color: #7a0874; font-weight: bold;">&#41;</span>    <span style="color: #c20cb9; font-weight: bold;">tar</span> xvzf $<span style="color: #000000;">1</span>     <span style="color: #000000; font-weight: bold;">;;</span>
            <span style="color: #000000; font-weight: bold;">*</span>.bz2<span style="color: #7a0874; font-weight: bold;">&#41;</span>       <span style="color: #c20cb9; font-weight: bold;">bunzip2</span> $<span style="color: #000000;">1</span>       <span style="color: #000000; font-weight: bold;">;;</span>
            <span style="color: #000000; font-weight: bold;">*</span>.rar<span style="color: #7a0874; font-weight: bold;">&#41;</span>       unrar x $<span style="color: #000000;">1</span>     <span style="color: #000000; font-weight: bold;">;;</span>
            <span style="color: #000000; font-weight: bold;">*</span>.gz<span style="color: #7a0874; font-weight: bold;">&#41;</span>        <span style="color: #c20cb9; font-weight: bold;">gunzip</span> $<span style="color: #000000;">1</span>     <span style="color: #000000; font-weight: bold;">;;</span>
            <span style="color: #000000; font-weight: bold;">*</span>.tar<span style="color: #7a0874; font-weight: bold;">&#41;</span>       <span style="color: #c20cb9; font-weight: bold;">tar</span> xvf $<span style="color: #000000;">1</span>        <span style="color: #000000; font-weight: bold;">;;</span>
            <span style="color: #000000; font-weight: bold;">*</span>.tbz2<span style="color: #7a0874; font-weight: bold;">&#41;</span>      <span style="color: #c20cb9; font-weight: bold;">tar</span> xvjf $<span style="color: #000000;">1</span>      <span style="color: #000000; font-weight: bold;">;;</span>
            <span style="color: #000000; font-weight: bold;">*</span>.tgz<span style="color: #7a0874; font-weight: bold;">&#41;</span>       <span style="color: #c20cb9; font-weight: bold;">tar</span> xvzf $<span style="color: #000000;">1</span>       <span style="color: #000000; font-weight: bold;">;;</span>
            <span style="color: #000000; font-weight: bold;">*</span>.zip<span style="color: #7a0874; font-weight: bold;">&#41;</span>       <span style="color: #c20cb9; font-weight: bold;">unzip</span> $<span style="color: #000000;">1</span>     <span style="color: #000000; font-weight: bold;">;;</span>
            <span style="color: #000000; font-weight: bold;">*</span>.Z<span style="color: #7a0874; font-weight: bold;">&#41;</span>         uncompress $<span style="color: #000000;">1</span>  <span style="color: #000000; font-weight: bold;">;;</span>
            <span style="color: #000000; font-weight: bold;">*</span>.7z<span style="color: #7a0874; font-weight: bold;">&#41;</span>        7z x $<span style="color: #000000;">1</span>    <span style="color: #000000; font-weight: bold;">;;</span>
            <span style="color: #000000; font-weight: bold;">*</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>           <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;'$1' cannot be extracted via &gt;extract&lt;&quot;</span> <span style="color: #000000; font-weight: bold;">;;</span>
        <span style="color: #000000; font-weight: bold;">esac</span>
    <span style="color: #000000; font-weight: bold;">else</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;'$1' is not a valid file&quot;</span>
    <span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
<span style="color: #666666; font-style: italic;">################## End functions from http://www.johnlawrence.net/code/?f=sfbashrc ###################################</span>
&nbsp;
<span style="color: #666666; font-style: italic;">################## Begin functions from http://foohack.com/tests/bash_extras/.extra.bashrc ###################################</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># chooses the first argument that matches a file in the path.</span>
choose_first <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">for</span> i <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #ff0000;">&quot;$@&quot;</span>; <span style="color: #000000; font-weight: bold;">do</span>
		<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #000000; font-weight: bold;">!</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-f</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$i</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> inpath <span style="color: #ff0000;">&quot;<span style="color: #007800;">$i</span>&quot;</span>; <span style="color: #000000; font-weight: bold;">then</span>
			<span style="color: #007800;">i</span>=<span style="color: #ff0000;">&quot;<span style="color: #780078;">`which $i`</span>&quot;</span>
		<span style="color: #000000; font-weight: bold;">fi</span>
		<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-f</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$i</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
			<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$i</span>
			<span style="color: #7a0874; font-weight: bold;">break</span>
		<span style="color: #000000; font-weight: bold;">fi</span>
	<span style="color: #000000; font-weight: bold;">done</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
inpath <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">!</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$#</span> <span style="color: #660033;">-eq</span> <span style="color: #000000;">1</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;usage: inpath &lt;file&gt;&quot;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #7a0874; font-weight: bold;">return</span> <span style="color: #000000;">1</span>
	<span style="color: #007800;">f</span>=<span style="color: #ff0000;">&quot;<span style="color: #780078;">`which $1 2&gt;/dev/null`</span>&quot;</span>
	<span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-f</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$f</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #7a0874; font-weight: bold;">return</span> <span style="color: #000000;">0</span>
	<span style="color: #7a0874; font-weight: bold;">return</span> <span style="color: #000000;">1</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># headless &lt;command&gt; [&lt;key&gt;]</span>
<span style="color: #666666; font-style: italic;"># to reconnect, do: headless &quot;&quot; &lt;key&gt;</span>
headless <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;$2&quot;</span> == <span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
		<span style="color: #007800;"><span style="color: #7a0874; font-weight: bold;">hash</span></span>=<span style="color: #000000; font-weight: bold;">`</span>md5 <span style="color: #660033;">-qs</span> <span style="color: #ff0000;">&quot;$1&quot;</span><span style="color: #000000; font-weight: bold;">`</span>
	<span style="color: #000000; font-weight: bold;">else</span>
		<span style="color: #007800;"><span style="color: #7a0874; font-weight: bold;">hash</span></span>=<span style="color: #ff0000;">&quot;$2&quot;</span>
	<span style="color: #000000; font-weight: bold;">fi</span>
	<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;$1&quot;</span> <span style="color: #000000; font-weight: bold;">!</span>= <span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
		dtach <span style="color: #660033;">-n</span> <span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>headless-<span style="color: #007800;">$hash</span> <span style="color: #c20cb9; font-weight: bold;">bash</span> <span style="color: #660033;">-l</span> <span style="color: #660033;">-c</span> <span style="color: #ff0000;">&quot;$1&quot;</span>
	<span style="color: #000000; font-weight: bold;">else</span>
		dtach <span style="color: #660033;">-A</span> <span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>headless-<span style="color: #007800;">$hash</span> <span style="color: #c20cb9; font-weight: bold;">bash</span> <span style="color: #660033;">-l</span>
	<span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># function to do something in the background</span>
back <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
	<span style="color: #7a0874; font-weight: bold;">&#40;</span> $<span style="color: #000000; font-weight: bold;">@</span> <span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #000000; font-weight: bold;">&amp;</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
<span style="color: #666666; font-style: italic;"># do something very quietly.</span>
quiet <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
	<span style="color: #7a0874; font-weight: bold;">&#40;</span> $<span style="color: #000000; font-weight: bold;">@</span> <span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #000000; font-weight: bold;">&gt;/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># useful commands:</span>
_set_editor <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
	<span style="color: #007800;">edit_cmd</span>=<span style="color: #ff0000;">&quot;<span style="color: #780078;">`choose_first $@`</span>&quot;</span>
	<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-f</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$edit_cmd</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
		<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-f</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${edit_cmd}</span>_wait&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
			<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">EDITOR</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">${edit_cmd}</span>_wait&quot;</span>
		<span style="color: #000000; font-weight: bold;">else</span>
			<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">EDITOR</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$edit_cmd</span>&quot;</span>
		<span style="color: #000000; font-weight: bold;">fi</span>
	<span style="color: #000000; font-weight: bold;">fi</span>
	<span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">edit</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$edit_cmd</span>&quot;</span>
	<span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">sued</span>=<span style="color: #ff0000;">&quot;sudo <span style="color: #007800;">$edit_cmd</span>&quot;</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
<span style="color: #666666; font-style: italic;"># my list of editors, by preference.</span>
_set_editor mate <span style="color: #c20cb9; font-weight: bold;">vim</span> <span style="color: #c20cb9; font-weight: bold;">vi</span> pico <span style="color: #c20cb9; font-weight: bold;">ed</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># shebang &lt;file&gt; &lt;program&gt; [&lt;args&gt;]</span>
shebang <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
	<span style="color: #007800;">sb</span>=<span style="color: #ff0000;">&quot;shebang&quot;</span>
	<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$#</span> <span style="color: #660033;">-lt</span> <span style="color: #000000;">2</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
		<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;usage: <span style="color: #007800;">$sb</span> &lt;file&gt; &lt;program&gt; [&lt;arg string&gt;]&quot;</span>
		<span style="color: #7a0874; font-weight: bold;">return</span> <span style="color: #000000;">1</span>
	<span style="color: #000000; font-weight: bold;">elif</span> <span style="color: #000000; font-weight: bold;">!</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-f</span> <span style="color: #ff0000;">&quot;$1&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
		<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$sb</span>: $1 is not a file.&quot;</span>
		<span style="color: #7a0874; font-weight: bold;">return</span> <span style="color: #000000;">1</span>
	<span style="color: #000000; font-weight: bold;">fi</span>
	<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #000000; font-weight: bold;">!</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-w</span> <span style="color: #ff0000;">&quot;$1&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
		<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$sb</span>: $1 is not writable.&quot;</span>
		<span style="color: #7a0874; font-weight: bold;">return</span> <span style="color: #000000;">1</span>
	<span style="color: #000000; font-weight: bold;">fi</span>
	<span style="color: #007800;">prog</span>=<span style="color: #ff0000;">&quot;$2&quot;</span>
	<span style="color: #000000; font-weight: bold;">!</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-f</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$prog</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #007800;">prog</span>=<span style="color: #ff0000;">&quot;<span style="color: #780078;">`which $prog 2&gt;/dev/null`</span>&quot;</span>
	<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #000000; font-weight: bold;">!</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-x</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$prog</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
		<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$sb</span>: $2 is not executable, or not in path.&quot;</span>
		<span style="color: #7a0874; font-weight: bold;">return</span> <span style="color: #000000;">1</span>
	<span style="color: #000000; font-weight: bold;">fi</span>
	<span style="color: #c20cb9; font-weight: bold;">chmod</span> ogu+x <span style="color: #ff0000;">&quot;$1&quot;</span>
	<span style="color: #007800;">prog</span>=<span style="color: #ff0000;">&quot;#!<span style="color: #007800;">$prog</span>&quot;</span>
	<span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;$3&quot;</span> <span style="color: #000000; font-weight: bold;">!</span>= <span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #007800;">prog</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$prog</span> $3&quot;</span>
	<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #000000; font-weight: bold;">!</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #780078;">`head -n 1 \&quot;$1\&quot;`</span>&quot;</span> == <span style="color: #ff0000;">&quot;<span style="color: #007800;">$prog</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
		<span style="color: #007800;">contents</span>=<span style="color: #ff0000;">&quot;<span style="color: #780078;">`cat \&quot;$1\&quot;`</span>&quot;</span>
		<span style="color: #007800;">newcontents</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #cc0000; font-style: italic;">&lt;&lt;ENDSHEBANG
$prog
$contents
ENDSHEBANG</span><span style="color: #000000; font-weight: bold;">`</span>
		<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$newcontents</span>&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;</span> $<span style="color: #000000;">1</span>
	<span style="color: #000000; font-weight: bold;">fi</span>
	<span style="color: #7a0874; font-weight: bold;">return</span> <span style="color: #000000;">0</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
rand <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
	<span style="color: #666666; font-style: italic;"># r=``</span>
	<span style="color: #666666; font-style: italic;"># echo $r</span>
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #000000; font-weight: bold;">`</span>php <span style="color: #660033;">-r</span> <span style="color: #ff0000;">'echo rand();'</span><span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
pickrand <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
	<span style="color: #007800;">cnt</span>=<span style="color: #000000;">0</span>
	<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$#</span> == <span style="color: #000000;">1</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
		<span style="color: #007800;">tst</span>=$<span style="color: #000000;">1</span>
	<span style="color: #000000; font-weight: bold;">else</span>
		<span style="color: #007800;">tst</span>=<span style="color: #ff0000;">&quot;-d&quot;</span>
	<span style="color: #000000; font-weight: bold;">fi</span>
	<span style="color: #000000; font-weight: bold;">for</span> i <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">*</span>; <span style="color: #000000; font-weight: bold;">do</span>
		<span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$tst</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$i</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #7a0874; font-weight: bold;">let</span> <span style="color: #ff0000;">'cnt += 1'</span>
	<span style="color: #000000; font-weight: bold;">done</span>
	<span style="color: #007800;">r</span>=<span style="color: #000000; font-weight: bold;">`</span>rand<span style="color: #000000; font-weight: bold;">`</span>
	<span style="color: #007800;">p</span>=<span style="color: #000000;">0</span>
	<span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$cnt</span> <span style="color: #660033;">-eq</span> <span style="color: #000000;">0</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #7a0874; font-weight: bold;">return</span> <span style="color: #000000;">1</span>
	<span style="color: #7a0874; font-weight: bold;">let</span> <span style="color: #ff0000;">'p = r % cnt'</span>
	<span style="color: #666666; font-style: italic;"># echo &quot;[$cnt $r --- $p]&quot;</span>
	<span style="color: #007800;">cnt</span>=<span style="color: #000000;">0</span>
	<span style="color: #000000; font-weight: bold;">for</span> i <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">*</span>; <span style="color: #000000; font-weight: bold;">do</span>
		<span style="color: #666666; font-style: italic;"># echo &quot;[$cnt]&quot;</span>
		<span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$tst</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$i</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #7a0874; font-weight: bold;">let</span> <span style="color: #ff0000;">'cnt += 1'</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$cnt</span> <span style="color: #660033;">-eq</span> <span style="color: #007800;">$p</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$i</span>&quot;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #7a0874; font-weight: bold;">return</span>
	<span style="color: #000000; font-weight: bold;">done</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># a friendlier delete on the command line</span>
<span style="color: #000000; font-weight: bold;">!</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-d</span> ~<span style="color: #000000; font-weight: bold;">/</span>.Trash <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #c20cb9; font-weight: bold;">mkdir</span> ~<span style="color: #000000; font-weight: bold;">/</span>.Trash
<span style="color: #c20cb9; font-weight: bold;">chmod</span> <span style="color: #000000;">700</span> ~<span style="color: #000000; font-weight: bold;">/</span>.Trash
<span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">emptytrash</span>=<span style="color: #ff0000;">&quot;find ~/.Trash -not -path ~/.Trash -exec rm -rf {} \; 2&gt;/dev/null&quot;</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #000000; font-weight: bold;">!</span> inpath del; <span style="color: #000000; font-weight: bold;">then</span>
	<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-d</span> ~<span style="color: #000000; font-weight: bold;">/</span>.Trash <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
		del <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
			<span style="color: #000000; font-weight: bold;">for</span> i <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #ff0000;">&quot;$@&quot;</span>; <span style="color: #000000; font-weight: bold;">do</span>
				<span style="color: #c20cb9; font-weight: bold;">mv</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$i</span>&quot;</span> ~<span style="color: #000000; font-weight: bold;">/</span>.Trash<span style="color: #000000; font-weight: bold;">/</span>
			<span style="color: #000000; font-weight: bold;">done</span>
		<span style="color: #7a0874; font-weight: bold;">&#125;</span>
	<span style="color: #000000; font-weight: bold;">else</span>
		<span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">del</span>=<span style="color: #c20cb9; font-weight: bold;">rm</span>
	<span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># find files in current dir by name (not in package dirs)</span>
f <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
	<span style="color: #c20cb9; font-weight: bold;">find</span> . <span style="color: #660033;">-name</span> <span style="color: #ff0000;">&quot;$1&quot;</span> <span style="color: #660033;">-not</span> <span style="color: #660033;">-path</span> <span style="color: #ff0000;">&quot;*/rhel.*.*.package/*&quot;</span> <span style="color: #660033;">-not</span> <span style="color: #660033;">-path</span> <span style="color: #ff0000;">&quot;*/CVS/*&quot;</span> <span style="color: #660033;">-not</span> <span style="color: #660033;">-path</span> <span style="color: #ff0000;">&quot;*/CVS&quot;</span> <span style="color: #660033;">-not</span> <span style="color: #660033;">-path</span> <span style="color: #ff0000;">&quot;*/rhel.*.*.package&quot;</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
getip <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">for</span> each <span style="color: #000000; font-weight: bold;">in</span> $<span style="color: #000000; font-weight: bold;">@</span>; <span style="color: #000000; font-weight: bold;">do</span>
		<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$each</span>
		<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;nslookup:&quot;</span>
		nslookup <span style="color: #007800;">$each</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> Address: <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-v</span> <span style="color: #ff0000;">'#'</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">egrep</span> <span style="color: #660033;">-o</span> <span style="color: #ff0000;">'([0-9]+\.){3}[0-9]+'</span>
		<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;ping:&quot;</span>
		<span style="color: #c20cb9; font-weight: bold;">ping</span> <span style="color: #660033;">-c1</span> <span style="color: #660033;">-t1</span> <span style="color: #007800;">$each</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">egrep</span> <span style="color: #660033;">-o</span> <span style="color: #ff0000;">'([0-9]+\.){3}[0-9]+'</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">head</span> <span style="color: #660033;">-n1</span>
	<span style="color: #000000; font-weight: bold;">done</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
ips <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
  ip addr show <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #660033;">-F</span><span style="color: #ff0000;">&quot;:&quot;</span> <span style="color: #ff0000;">'($1&gt;0){split($2,a,&quot; &quot;);print a[1] &quot;- &quot;}($1 ~ /([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/){split($1,a,&quot; &quot;); print a[2]}'</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">tr</span> <span style="color: #ff0000;">'\n'</span> <span style="color: #ff0000;">'\t'</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #ff0000;">'s/\/[0-9]\+//g'</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #ff0000;">'s/\(\w\+\)-/\n\1/g'</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #ff0000;">'/^$/d'</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #7a0874; font-weight: bold;">echo</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
macs <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
  ip addr show <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #660033;">-F</span><span style="color: #ff0000;">&quot;:&quot;</span> <span style="color: #ff0000;">'($1&gt;0){split($2,a,&quot; &quot;);print a[1] &quot;- &quot;}($1 ~ /link/){split($0,a,&quot; &quot;); print a[2]}'</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">tr</span> <span style="color: #ff0000;">'\n'</span> <span style="color: #ff0000;">'\t'</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #ff0000;">'s/\/[0-9]\+//g'</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #ff0000;">'s/\(\w\+\)-/\n\1/g'</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #ff0000;">'/^$/d'</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #7a0874; font-weight: bold;">echo</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
pg <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
	<span style="color: #c20cb9; font-weight: bold;">ps</span> aux <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> $<span style="color: #000000; font-weight: bold;">@</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-v</span> <span style="color: #c20cb9; font-weight: bold;">grep</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
pid <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
	pg $<span style="color: #000000; font-weight: bold;">@</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{print $2}'</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
repeat <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;$2&quot;</span> == <span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
		<span style="color: #007800;">delay</span>=<span style="color: #000000;">1</span>
	<span style="color: #000000; font-weight: bold;">else</span>
		<span style="color: #007800;">delay</span>=$<span style="color: #000000;">2</span>
	<span style="color: #000000; font-weight: bold;">fi</span>
	<span style="color: #000000; font-weight: bold;">while</span> <span style="color: #c20cb9; font-weight: bold;">sleep</span> <span style="color: #007800;">$delay</span>; <span style="color: #000000; font-weight: bold;">do</span>
		<span style="color: #c20cb9; font-weight: bold;">clear</span>
		<span style="color: #c20cb9; font-weight: bold;">date</span> +<span style="color: #000000; font-weight: bold;">%</span>s
		$<span style="color: #000000;">1</span>
	<span style="color: #000000; font-weight: bold;">done</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
watch <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;$2&quot;</span> == <span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
		<span style="color: #007800;">delay</span>=<span style="color: #000000;">1</span>
	<span style="color: #000000; font-weight: bold;">else</span>
		<span style="color: #007800;">delay</span>=<span style="color: #ff0000;">&quot;$2&quot;</span>
	<span style="color: #000000; font-weight: bold;">fi</span>
	<span style="color: #007800;">i</span>=<span style="color: #ff0000;">&quot;&quot;</span>;
	<span style="color: #007800;">j</span>=<span style="color: #ff0000;">&quot;&quot;</span>;
	<span style="color: #000000; font-weight: bold;">while</span> <span style="color: #c20cb9; font-weight: bold;">sleep</span> <span style="color: #007800;">$delay</span>; <span style="color: #000000; font-weight: bold;">do</span>
		<span style="color: #007800;">i</span>=<span style="color: #000000; font-weight: bold;">`</span>$<span style="color: #000000;">1</span><span style="color: #000000; font-weight: bold;">`</span>;
		<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$i</span>&quot;</span> <span style="color: #000000; font-weight: bold;">!</span>= <span style="color: #ff0000;">&quot;<span style="color: #007800;">$j</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
			<span style="color: #c20cb9; font-weight: bold;">date</span> +<span style="color: #000000; font-weight: bold;">%</span>s
			<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$i</span>
		<span style="color: #000000; font-weight: bold;">fi</span>
	<span style="color: #000000; font-weight: bold;">done</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># more persistent wget for fetching files to a specific filename.</span>
fetch_to <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
	<span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$#</span> <span style="color: #660033;">-ne</span> <span style="color: #000000;">2</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;usage: fetch_to &lt;url&gt; &lt;filename&gt;&quot;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #7a0874; font-weight: bold;">return</span> <span style="color: #000000;">1</span>
	<span style="color: #007800;">urltofetch</span>=$<span style="color: #000000;">1</span>
	<span style="color: #007800;">fname</span>=<span style="color: #ff0000;">&quot;$2&quot;</span>
	<span style="color: #c20cb9; font-weight: bold;">wget</span> <span style="color: #660033;">-O</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$fname</span>&quot;</span> <span style="color: #007800;">$urltofetch</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">################## End functions from http://foohack.com/tests/bash_extras/.extra.bashrc ###################################</span></pre></div></div>

<p>Durch Aufruf von</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>.bashrc</pre></div></div>

<p>kann man ohne Neustart der Shell die Konfigurationsdatei laden. Die in der .bashrc referenzierte .bash_aliases sieht folgendermaßen aus:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># Alias definitions</span>
<span style="color: #666666; font-style: italic;"># some more ls aliases</span>
<span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">ll</span>=<span style="color: #ff0000;">'ls -lF'</span>
<span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">la</span>=<span style="color: #ff0000;">'ls -aF'</span>
<span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">lla</span>=<span style="color: #ff0000;">'ls -laF'</span>
<span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">l</span>=<span style="color: #ff0000;">'ls -CF'</span>
<span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;"><span style="color: #c20cb9; font-weight: bold;">ld</span></span>=<span style="color: #ff0000;">'ls -al -d * | egrep &quot;^d&quot;'</span> <span style="color: #666666; font-style: italic;"># only subdirectories</span>
<span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">lt</span>=<span style="color: #ff0000;">'ls -alt | head -20'</span> <span style="color: #666666; font-style: italic;"># recently changed files</span>
<span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">ag</span>=<span style="color: #ff0000;">&quot;alias | <span style="color: #007800;">$grep</span>&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># convenience redefinitions</span>
<span style="color: #7a0874; font-weight: bold;">alias</span> cd..=<span style="color: #ff0000;">'cd ..'</span>
<span style="color: #7a0874; font-weight: bold;">alias</span> cd-=<span style="color: #ff0000;">'cd -'</span>
<span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;"><span style="color: #c20cb9; font-weight: bold;">dselect</span></span>=<span style="color: #ff0000;">'dselect --expert'</span>
<span style="color: #7a0874; font-weight: bold;">alias</span> fg-=<span style="color: #ff0000;">'fg -'</span>
<span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;"><span style="color: #c20cb9; font-weight: bold;">more</span></span>=<span style="color: #ff0000;">&quot;less -e&quot;</span>
<span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">lsdevs</span>=<span style="color: #ff0000;">&quot;sudo lsof | <span style="color: #007800;">$grep</span> /dev&quot;</span>
<span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">md</span>=<span style="color: #ff0000;">'mkdir -p'</span>
<span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">rd</span>=<span style="color: #c20cb9; font-weight: bold;">rmdir</span>
<span style="color: #7a0874; font-weight: bold;">alias</span> ..=<span style="color: #ff0000;">'cd ..'</span>
<span style="color: #7a0874; font-weight: bold;">alias</span> ...=<span style="color: #ff0000;">'cd ../..'</span>
<span style="color: #666666; font-style: italic;">#also remember popd</span>
<span style="color: #7a0874; font-weight: bold;">alias</span> +=<span style="color: #ff0000;">'pushd .'</span>
<span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">mvsafe</span>=<span style="color: #ff0000;">&quot;mv -i&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># enable color support of ls and also add handy aliases</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$TERM</span>&quot;</span> <span style="color: #000000; font-weight: bold;">!</span>= <span style="color: #ff0000;">&quot;dumb&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-x</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><span style="color: #c20cb9; font-weight: bold;">dircolors</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
    <span style="color: #7a0874; font-weight: bold;">eval</span> <span style="color: #ff0000;">&quot;<span style="color: #780078;">`dircolors -b`</span>&quot;</span>
    <span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;"><span style="color: #c20cb9; font-weight: bold;">ls</span></span>=<span style="color: #ff0000;">'ls --color=auto'</span>
    <span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;"><span style="color: #c20cb9; font-weight: bold;">dir</span></span>=<span style="color: #ff0000;">'ls --color=auto --format=vertical'</span>
    <span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;"><span style="color: #c20cb9; font-weight: bold;">vdir</span></span>=<span style="color: #ff0000;">'ls --color=auto --format=long'</span>
&nbsp;
    <span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;"><span style="color: #c20cb9; font-weight: bold;">grep</span></span>=<span style="color: #ff0000;">'grep --color=auto'</span>
    <span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;"><span style="color: #c20cb9; font-weight: bold;">fgrep</span></span>=<span style="color: #ff0000;">'fgrep --color=auto'</span>
    <span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;"><span style="color: #c20cb9; font-weight: bold;">egrep</span></span>=<span style="color: #ff0000;">'egrep --color=auto'</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># inventions</span>
<span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">fgg</span>=<span style="color: #7a0874; font-weight: bold;">jobs</span>
<span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">ghist</span>=<span style="color: #ff0000;">'history|grep'</span>
<span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">lf</span>=<span style="color: #ff0000;">'find -type f|sort'</span>
<span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">load</span>=<span style="color: #ff0000;">'cat /proc/loadavg'</span>
<span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">meminfo</span>=<span style="color: #ff0000;">'cat /proc/meminfo'</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Kalendar</span>
<span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">kal</span>=<span style="color: #ff0000;">'clear;echo -n &quot;Heutiges Datum: &quot;;date;echo;cal -3m'</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#make tree a little cooler looking.</span>
<span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;"><span style="color: #c20cb9; font-weight: bold;">tree</span></span>=<span style="color: #ff0000;">&quot;tree -CAFa -I 'CVS|rhel.*.*.package|.svn|.git' --dirsfirst&quot;</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">processes</span>=<span style="color: #ff0000;">&quot;ps axMuc | egrep '^[a-zA-Z0-9]'&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># command-line perl prog</span>
<span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">pie</span>=<span style="color: #ff0000;">&quot;perl -p -i -e &quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">################## Begin functions from http://www.johnlawrence.net/code/?f=sfbashrc ###################################</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># directory tree - http://www.shell-fu.org/lister.php?id=209</span>
<span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">dirf</span>=<span style="color: #ff0000;">'find . -type d | sed -e &quot;s/[^-][^\/]*\//  |/g&quot; -e &quot;s/|\([^ ]\)/|-\1/&quot;'</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#calendar with today highlighted - http://www.shell-fu.org/lister.php?id=210</span>
<span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">tcal</span>=<span style="color: #ff0000;">'cal | sed &quot;s/^/ /;s/$/ /;s/ $(date +%e) / $(date +%e | sed '</span><span style="color: #000000; font-weight: bold;">\'</span><span style="color: #ff0000;">'s/./#/g'</span><span style="color: #000000; font-weight: bold;">\'</span><span style="color: #ff0000;">') /&quot;'</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># count files by type - http://www.shell-fu.org/lister.php?id=173</span>
<span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">ftype</span>=<span style="color: #ff0000;">'find ${*-.} -type f | xargs file | awk -F, '</span><span style="color: #000000; font-weight: bold;">\'</span><span style="color: #ff0000;">'{print $1}'</span><span style="color: #000000; font-weight: bold;">\'</span><span style="color: #ff0000;">' | awk '</span><span style="color: #000000; font-weight: bold;">\'</span><span style="color: #ff0000;">'{$1=NULL;print $0}'</span><span style="color: #000000; font-weight: bold;">\'</span><span style="color: #ff0000;">' | sort | uniq -c | sort -nr'</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># convert permissions to octal - http://www.shell-fu.org/lister.php?id=205</span>
<span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">lo</span>=<span style="color: #ff0000;">'ls -l | sed -e '</span>s<span style="color: #000000; font-weight: bold;">/</span>--x<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">1</span><span style="color: #000000; font-weight: bold;">/</span>g<span style="color: #ff0000;">' -e '</span>s<span style="color: #000000; font-weight: bold;">/</span>-w-<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">/</span>g<span style="color: #ff0000;">' -e '</span>s<span style="color: #000000; font-weight: bold;">/</span>-wx<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">3</span><span style="color: #000000; font-weight: bold;">/</span>g<span style="color: #ff0000;">' -e '</span>s<span style="color: #000000; font-weight: bold;">/</span>r--<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">4</span><span style="color: #000000; font-weight: bold;">/</span>g<span style="color: #ff0000;">' -e '</span>s<span style="color: #000000; font-weight: bold;">/</span>r-x<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">5</span><span style="color: #000000; font-weight: bold;">/</span>g<span style="color: #ff0000;">' -e '</span>s<span style="color: #000000; font-weight: bold;">/</span>rw-<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">6</span><span style="color: #000000; font-weight: bold;">/</span>g<span style="color: #ff0000;">' -e '</span>s<span style="color: #000000; font-weight: bold;">/</span>rwx<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">7</span><span style="color: #000000; font-weight: bold;">/</span>g<span style="color: #ff0000;">' -e '</span>s<span style="color: #000000; font-weight: bold;">/</span>---<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">0</span><span style="color: #000000; font-weight: bold;">/</span>g<span style="color: #ff0000;">''</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># portscan in one line - http://www.shell-fu.org/lister.php?id=295</span>
portscan<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#123;</span>
  <span style="color: #007800;">HOST</span>=<span style="color: #ff0000;">&quot;$1&quot;</span>;<span style="color: #000000; font-weight: bold;">for</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #007800;">port</span>=<span style="color: #000000;">1</span>;port<span style="color: #000000; font-weight: bold;">&lt;</span>=<span style="color: #000000;">65535</span>;++port<span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>;<span style="color: #000000; font-weight: bold;">do</span> <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-en</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$port</span> &quot;</span>;<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-en</span> <span style="color: #ff0000;">&quot;open <span style="color: #007800;">$HOST</span> <span style="color: #007800;">$port</span><span style="color: #000099; font-weight: bold;">\n</span>logout\quit&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> telnet <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #ff0000;">'Connected to'</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null;<span style="color: #000000; font-weight: bold;">then</span> <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-en</span> <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>port <span style="color: #007800;">$port</span>/tcp is open<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>;<span style="color: #000000; font-weight: bold;">fi</span>;<span style="color: #000000; font-weight: bold;">done</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># print a random shell-fu tip - http://www.shell-fu.org/lister.php?id=192</span>
<span style="color: #7a0874; font-weight: bold;">alias</span> shell-fu=<span style="color: #ff0000;">'links -dump &quot;http://www.shell-fu.org/lister.php?random&quot; | grep -A 100 -- ----'</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># get an ordered list of subdirectory sizes - http://www.shell-fu.org/lister.php?id=275</span>
<span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">dux</span>=<span style="color: #ff0000;">'du -sk ./* | sort -n | awk '</span><span style="color: #000000; font-weight: bold;">\'</span><span style="color: #ff0000;">'BEGIN{ pref[1]=&quot;K&quot;; pref[2]=&quot;M&quot;; pref[3]=&quot;G&quot;;} { total = total + $1; x = $1; y = 1; while( x &gt; 1024 ) { x = (x + 1023)/1024; y++; } printf(&quot;%g%s\t%s\n&quot;,int(x*10)/10,pref[y],$2); } END { y = 1; while( total &gt; 1024 ) { total = (total + 1023)/1024; y++; } printf(&quot;Total: %g%s\n&quot;,int(total*10)/10,pref[y]); }'</span><span style="color: #000000; font-weight: bold;">\'</span><span style="color: #ff0000;">''</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># share current tree over the web - http://www.shell-fu.org/lister.php?id=54</span>
<span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">webshare</span>=<span style="color: #ff0000;">'python -c &quot;import SimpleHTTPServer;SimpleHTTPServer.test()&quot;'</span>
&nbsp;
<span style="color: #666666; font-style: italic;">################## End functions from http://www.johnlawrence.net/code/?f=sfbashrc ###################################</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.effinger.org/blog/2008/11/20/arbeitserleichterung-durch-bashrc-und-bash_aliases/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Dash Shell Scripting &#8211; Mit Arrays arbeiten</title>
		<link>http://www.effinger.org/blog/2008/11/20/dash-shell-scripting-mit-arrays-arbeiten/</link>
		<comments>http://www.effinger.org/blog/2008/11/20/dash-shell-scripting-mit-arrays-arbeiten/#comments</comments>
		<pubDate>Thu, 20 Nov 2008 21:03:46 +0000</pubDate>
		<dc:creator>Markus Effinger</dc:creator>
				<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[dash]]></category>
		<category><![CDATA[Shell]]></category>

		<guid isPermaLink="false">http://www.effinger.org/blog/?p=221</guid>
		<description><![CDATA[<p>Bei der Bourne-Shell ist es ohne Probleme möglich verschiedenste Dinge mit Arrays anzustellen. Viele interessante und lehrreiche Beispiele finden sich im Unix Bash Scripting Blog. Allerdings verwendet Ubuntu für Scripts mittlerweile die dash, die zwar nicht den Funktionsumfang der Bash bereitstellt, aber dafür dem POSIX-Standard entspricht und schneller sein soll. Leider kann man damit nicht [...]]]></description>
			<content:encoded><![CDATA[<p>Bei der Bourne-Shell ist es ohne Probleme möglich verschiedenste Dinge mit Arrays anzustellen. Viele interessante und lehrreiche Beispiele finden sich im <a href="http://unstableme.blogspot.com/2008/06/using-array-in-bash-script.html">Unix Bash Scripting Blog</a>. Allerdings verwendet Ubuntu für Scripts mittlerweile die dash, die zwar nicht den Funktionsumfang der Bash bereitstellt, aber dafür dem POSIX-Standard entspricht und schneller sein soll. Leider kann man damit nicht wie von der Bash gewohnt mit Arrays arbeiten. Wie kann man sich nun behelfen? Ich wollte für mein Beispiel zwei Arrays (TAPS, ARP_IPS) so kombinieren, dass jeweils die zusammengehörigen Parameter (gleicher Index im Array) ausgegeben werden. So habe ich es hinbekommen:</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: #007800;">TAPS</span>=<span style="color: #ff0000;">&quot;tap0 tap1 tap2&quot;</span>
<span style="color: #007800;">ARP_IPS</span>=<span style="color: #ff0000;">&quot;169.254.0.1/32 169.254.0.2/32 169.254.0.3/32&quot;</span>
<span style="color: #007800;">i</span>=<span style="color: #000000;">0</span>
<span style="color: #000000; font-weight: bold;">for</span> TAP <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #007800;">$TAPS</span>; <span style="color: #000000; font-weight: bold;">do</span>
  <span style="color: #007800;">j</span>=<span style="color: #000000;">0</span>
  <span style="color: #000000; font-weight: bold;">for</span> ARP_IP <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #007800;">$ARP_IPS</span>; <span style="color: #000000; font-weight: bold;">do</span>
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$i</span> = <span style="color: #007800;">$j</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
      <span style="color: #7a0874; font-weight: bold;">break</span>
    <span style="color: #000000; font-weight: bold;">fi</span>
    <span style="color: #007800;">j</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span> <span style="color: #007800;">$j</span> + <span style="color: #000000;">1</span> <span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
  <span style="color: #000000; font-weight: bold;">done</span>
  <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$TAP</span> <span style="color: #007800;">$ARP_IP</span>
  <span style="color: #007800;">i</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span> <span style="color: #007800;">$i</span> + <span style="color: #000000;">1</span> <span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #000000; font-weight: bold;">done</span></pre></div></div>

<p>Als Ausgabe des Scripts erhält man folgendes:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">tap0 169.254.0.1<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">32</span>
tap1 169.254.0.2<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">32</span>
tap2 169.254.0.3<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">32</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.effinger.org/blog/2008/11/20/dash-shell-scripting-mit-arrays-arbeiten/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
