From 1c347911491f1dfed7927b2a03588470db7f6943 Mon Sep 17 00:00:00 2001 From: Valentin Gehrke Date: Tue, 6 Oct 2015 08:00:57 +0200 Subject: [PATCH] Added extract.sh (Not working yet) --- scripts/extract.sh | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100755 scripts/extract.sh diff --git a/scripts/extract.sh b/scripts/extract.sh new file mode 100755 index 0000000..a145841 --- /dev/null +++ b/scripts/extract.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +extract_targz() { tar -xzvf "$1" } +extract_tarbz() { tar -xjvf "$1" } +extract_tarxz() { tar -xJvf "$1" } +extract_rar() { unrar x "$1" } +extract_zip() { unzip "$1" } + +extractfile() { + case "$1" in + *.tar.gz|*.tgz) + extract_targz "$1" + ;; + *.tar.bz) + extract_tarbz "$1" + ;; + *.tar.xz) + extract_tarxz "$1" + ;; + *.rar) + extract_rar "$1" + ;; + *.zip) + extract_zip "$1" + ;; + esac +} + +for file in $@; do + extractfile "$file"; +done