Hi,
I'm trying to adapt a bash function to extract compressed files depending
on the tool used to compress them:

function ex

         # ex - archive extractor

         # usage: ex <file>

         if test -f $1

            switch $1

                   case *.tar.bz2

                        tar xjfv $1

                   case *.tar.gz

                        tar xzfv $1

                   case *.bz2

                        bunzip2 $1

                   case *.rar

                        unrar x $1

                   case *.gz

                        gunzip $1

                   case *.tar

                        tar xfv $1

                   case *.tbz2

                        tar xjfv $1

                   case *.tgz

                        tar xzfv $1

                   case *.xz

                        xz -dv $1

                   case *.zip

                        unzip $1

                   case *.Z

                        uncompress $1

                   case *.7z

                        7z x $1

                   case '*'

                        echo "'$1' cannot be extracted via ex()"

            end

         else

            echo "'$1' is not a valid file"

         end

end

Of course this isn't working at this time so my question is: how do I do to
make switch correctly parse the file name?

Best regards,
-Martin
------------------------------------------------------------------------------
_______________________________________________
Fish-users mailing list
Fish-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/fish-users

Reply via email to