extracting compressed files


Fed up of remembering the syntax for tar / tar.gz / zip / rar / Z … try adding this simple ‘extract’ function your .bashrc

#extract - extract most common compression types
function extract () {
    echo Extracting $1 ...
    if [ -f $1 ] ; then
        case $1 in
            *.tar.bz2)   tar xjf $1  ;;
            *.tar.gz)    tar xzf $1  ;;
            *.bz2)       bunzip2 $1  ;;
            *.rar)       rar x $1    ;;
            *.gz)        gunzip $1   ;;
            *.tar)       tar xf $1   ;;
            *.tbz2)      tar xjf $1  ;;
            *.tgz)       tar xzf $1  ;;
            *.zip)       unzip $1   ;;
            *.Z)         uncompress $1  ;;
            *.7z)        7z x $1  ;;
            *)        echo "'$1' cannot be extracted via extract()" ;;
        echo "'$1' is not a valid file"

3 Responses to “extracting compressed files”

  1. http://chilp.it/39fa97 Says:

    Wow, this post is pleasant, my younger sister is analyzing these things,
    so I am going to tell her.

  2. from quest protein bars this Says:

    naturally like your website but you need to check the spelling on several of your posts.
    Many of them are rife with spelling problems and I
    to find it very troublesome to tell the reality then again I’ll
    definitely come back again.

  3. jungekirche-dortmund.de Says:

    Informative article, exactly what I needed. Quest Bars blogesaurus

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: