Bequemes Öffnen von Archivdateien aus der Befehlszeile

Mit diesem einfachen Skript kannst du alle Archivformate (komprimiert oder nicht) mit einem einzigen Kommando extrahieren. Kopiere den untenstehenden Text in dein Textverarbeitungsprogramm und speichere ihn unter einfachem Namen (z.B. auf) in ein beliebiges /bin-Verzeichnis (z.B. /usr/local/bin). Dann mache die Datei ausführbar mit dem Befehl chmod 777 /usr/local/bin/auf.
Nun kannst du koprimierte Dateien mit x-beliebiger Endung mit dem Befehl auf öffnen. Wechsle dazu mit cd ins Verzeichnis des tar- oder zip-Archivs und gib dort in der Konsole ein: auf [dateiname]. Du kannst den Dateinamen auch nur andeuten und dann mit der Taste [TAB] vervollständigen. Es wird im gleichen Verzeichnis ein neues Unterverzeichnis mit dem Namen des extrahierten Archivs erstellt.

Easy opening of archives on the command line

By means of this simple script you can extract archives in any format (compressed or not) with a single command. Just copy the text below into your word processer and save it under an easy-to-remember name (e.g. open into any /bin directory like for instance /usr/local/bin. Then make the file executable with the command chmod 777 /usr/local/bin/open.
Now you can open any compressed data file with the simple command open. To do that, cd into the directory where the tar or zip archive resides and enter open [file name]. In case of very long names, you can indicate the full name with a few letters and then press the [TAB] button for auto-completion. A new sub-directory with the name of the archive is created instantaneously.


#!/bin/sh
# Skript zum Öffnen x-beliebiger Archivdateien
# Script for easy opening of archives
while [ x"$1" != x ]; do
case "$1" in
*.tar.gz | *.tgz )
tar xvzf "$1"
shift
;;
*.tar.bz2 | *.tbz )
tar xvjf "$1"
shift
;;
*.zip)
unzip "$1"
shift
;;
*.ace)
unace e "$1"
shift
;;
*.rar)
unrar e "$1"
shift
;;
*.tar)
tar xf "$1"
shift
;;
*.gz)
gunzip "$1"
shift
;;
*.bz2)
bunzip2 "$1"
shift
;;
*)
shift
;;
esac
done


Viel Spass!

Enjoy!