Unpack

De ULBwiki

--Kamus Hadenes 03h02min de 17 de Julho de 2008 (UTC)

Acha complicado decorar todos aqueles comandos chatos para se extrair arquivos? Para usuários iniciantes, decorar estes comandos é muito chato. Para os usuários mais avançados, isso gasta um precioso tempo. Este script visa facilitar sua vida. Seu uso é simples. Coloque o script em /bin/unpack e rode.

 unpack arquivo.tgz

Não é preciso especificar o tipo de arquivo, pois ele irá ver isto pela sua extensão. Em próximas versões, pretendo aprimorar isto, fazendo com que ele identifique o mimetype do arquivo e extraia, independente da extensão. Eis o script:

#!/bin/sh
 
#       unpack
#       
#       Copyright 2009 Kamus Hadenes <kamushadenes@gmail.com>
#       
#       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 2 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, write to the Free Software
#       Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
#       MA 02110-1301, USA.
while [ x"$1" != x ]; do
 case "$1" in
	*.tar.gz | *.tgz )
		tar -xzf "$1"
		shift
	;;
	*.tar.bz2 | *.tbz )
		tar -xjf "$1"
		shift
	;;
	*.zip)
		unzip "$1"
		shift
	;;
	*.jar)
		unzip "$1"
		shift
	;;
	*.war)
		unzip "$1"
		shift
	;;
	*.ace)
		unace e "$1"
		shift
	;;
	*.rar)
		unrar x "$1"
		shift
	;;
	*.tar)
		tar -xf "$1"
		shift
	;;
	*.gz)
		gunzip "$1"
		shift
	;;
	*.bz2)
		bunzip2 "$1"
		shift
	;;
	*.rpm)
		rpmextract.sh "$1"
		shift
	;;
	*.tbz2)
		tar xjf $1 
	;;
	*.tgz) 
		tar xzf $1 
	;;
	*.Z) 
		uncompress $1 
	;;
	*.7z) 
		7z x $1 
	;;
	*)
		echo "File format not supported"
		shift
	;;
	esac
done

Dependências: unzip, unrar, rpmextract, tar, p7zip, unace.

Ferramentas pessoais
Criar página