[SCRIPT] Unpack compressed files

Post tutorials, HOWTO's and other useful resources here.
User avatar
brokenman
Site Admin
Site Admin
Posts: 6105
Joined: 27 Dec 2010, 03:50
Distribution: Porteus v4 all desktops
Location: Brazil

[SCRIPT] Unpack compressed files

Post#1 by brokenman » 29 Dec 2010, 06:34

Do you keep forgetting the different switches for unpacking tarballs?

Paste this into a text file, save it as /usr/bin/unpack
Make it executable: chmod +x /usr/bin/unpack
Now to unpack most compressed files just use: unpack myfile.tar.bz2

Code: Select all

#!/bin/bash

INPUT=$1
FEXT=$(echo $1 | grep -o '\.[^.]*$')
case "$FEXT" in
".bz2")
tar -jxvf $INPUT;
;;
".gz")
tar -zxvf $INPUT
;;
".tar")
tar -xvf $INPUT;
;;
".zip")
unzip $INPUT;
esac
How do i become super user?
Wear your underpants on the outside and put on a cape.