All in One Unarchive Bash Script Linux -


i found following script online. instructions add ~/.bashrc. worked fine until installed 64 bit version of linux distro. (kali linux - debian wheezy ). i'm not sure what's going on. why isn't working, , how can fix it? i'm relatively new linux, , new bash scripting. script:

#!/bin/bash # function extract common file formats  function extract {  if [ -z "$1" ];     # display usage if no parameters given     echo "usage: extract <path/file_name>.<zip|rar|bz2|gz|tar|tbz2|tgz|z|7z|xz|ex|tar.bz2|tar.gz|tar.xz>"  else     if [ -f $1 ] ;         # name=${1%.*}         # mkdir $name && cd $name         case $1 in           *.tar.bz2)   tar xvjf ../$1    ;;           *.tar.gz)    tar xvzf ../$1    ;;           *.tar.xz)    tar xvjf ../$1    ;;           *.lzma)      unlzma ../$1      ;;           *.bz2)       bunzip2 ../$1     ;;           *.rar)       unrar x -ad ../$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        ;;           *.xz)        unxz ../$1        ;;           *.exe)       cabextract ../$1  ;;           *)           echo "extract: '$1' - unknown archive method" ;;         esac     else         echo "$1 - file not exist"     fi fi } 

error:

 extract libreoffice.tar.gz  tar (child): ../libreoffice.tar.gz: cannot open: no such file or directory tar (child): error not recoverable: exiting tar: child returned status 2 tar: error not recoverable: exiting 

edit: uncommenting name=... , mkdir $name... uncompresses tar fine. didn't unzip .zip, though. trying out different file right now.

edit 2: feel stupid. didn't bother looking @ code before posted this. uncommenting fixes this. however, why have uncomment code now, before installed 64 bit version, didn't?

the problem solved uncommenting.

# name=${1%.*}

# mkdir $name && cd $name


Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

javascript - Using Windows Media Player as video fallback for video tag -

c# - Unity IoC Lifetime per HttpRequest for UserStore -