From e443ba89d07541516d7bd80f78cb0e16e535e870 Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Sun, 2 Nov 2008 23:52:22 +0100 Subject: added wgetpaste and copy of extract.sh --- extract.sh | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100755 extract.sh (limited to 'extract.sh') diff --git a/extract.sh b/extract.sh new file mode 100755 index 0000000..bbb317a --- /dev/null +++ b/extract.sh @@ -0,0 +1,52 @@ +#!/bin/bash +#----------------------------------------------------# +# File: ~/bin/extract.sh # +# Version: 0.1.0 # +# Date: 2008-11-02 # +# Author: Florian "Bluewind" Pritz # +# Extract an archive based on the mime type # +#----------------------------------------------------# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +if [ "$1" = "" ] || [ "$1" = "-h" ]; then + echo -e "${blue}Usage:$NC $0 "; + echo -e "Extracts "; + echo -e "Also accepts multiple files"; + exit 0 +fi +for file in "$@" +do + if [ -f ${file} ] ; then + case ${file} in + *.tar.bz2) tar xjf ${file} ;; + *.tar.gz) tar xzf ${file} ;; + *.tbz2) tar xjf ${file} ;; + *.tgz) tar xzf ${file} ;; + *) + case $(file -bi ${file}) in + application/x-bzip2) bunzip2 ${file};; + application/rar) unrar x ${file};; + application/x-gzip) gunzip ${file};; + application/x-tar) tar xf ${file};; + application/zip) unzip ${file};; + application/x-compressed) uncompress ${file};; + application/x-7z-compressed) 7z x ${file};; + *) echo -e "${RED}Error:$NC No rule how to extract \"${file}\" ($(file -bi ${file}))" ;; + esac + ;; + esac + else + echo -e "${RED}Error:$NC \"${file}\" doesn't exist" + fi +done -- cgit v1.2.3-24-g4f1b