Topic: HOWTO: Extract compressed files in terminals or console
I know that this is easily done using Fileroller or similar GUI applications.
But I like to do most of my file operations using Terminals, because it's faster and I always gets the appropriate outputs if something goes wrong.
This tip is from the Arch Wiki and is one of my favourites ![]()
Open ~/.bashrc in your preferred editor and paste the following in the bottom of this file:
extract () {
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xvjf $1 ;;
*.tar.gz) tar xvzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) rar x $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xvf $1 ;;
*.tbz2) tar xvjf $1 ;;
*.tgz) tar xvzf $1 ;;
*.zip) unzip $1 ;;
*.Z) uncompress $1 ;;
*.7z) 7z x $1 ;;
*) echo "don't know how to extract '$1'..." ;;
esac
else
echo "'$1' is not a valid file!"
fi
}For making this to take effect immediately type this command in your preferred terminal:
source .bashrcFind a compressed file ie. (foo.tar.gz) and type this:
extract foo.tar.gzVoila ![]()
Last edited by Scrat (2009-01-13 11:01:27)
Registered Linux user #133791 > Get counted at http://counter.li.org
-----------------------------------------------------------------------
So Many Things To Do, And No Time For Nuts !