shell-script-pt
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [shell-script] função extract


From: Reinaldo de Carvalho
Subject: Re: [shell-script] função extract
Date: Tue, 3 Feb 2009 19:22:46 -0300

2009/2/3 Guilherme Gall <address@hidden>:
> 2009/2/3 voyeg3r <address@hidden>:
>
> #!/bin/bash
>
> extract(){
>   for file in "$@"; do
>      if [ -f "$file" ]; then
>         case "$file" in
>            *.tar.bz2)   tar xvjf "$file";;
>            *.tar.gz)   tar xvzf "$file";;
>            *.bz2)      bunzip2 "$file";;
>            *.rar)      rar x "$file";;
>            *.gz)      gunzip "$file";;
>            *.tar)      tar xvf "$file";;
>            *.tbz2)      tar xvjf "$file";;
>            *.tgz)      tar xvzf "$file";;
>            *.zip)      unzip "$file";;
>            *.Z)      uncompress "$file";;
>            *.7z)      7z x "$file";;
>            *)      echo "não sei como extrair '$file'...";;
>         esac
>      else
>         echo "'$file' não é um arquivo válido"
>      fi
>   done
> }
>
> # Fim do script

Fora que da pra unir essas opções:

            *.tar.bz2|*.tbz2)   tar xvjf "$file";;
            *.tar.gz|*.tgz)   tar xvzf "$file";;
            *.bz2)      bunzip2 "$file";;
            *.rar)      rar x "$file";;
            *.gz)      gunzip "$file";;
            *.tar)      tar xvf "$file";;
            *.zip)      unzip "$file";;
            *.Z)      uncompress "$file";;
            *.7z)      7z x "$file";;
            *)      echo "não sei como extrair '$file'...";;



-- 
Reinaldo de Carvalho
http://korreio.sf.net (Now available in English)
http://python-cyrus.sf.net


reply via email to

[Prev in Thread] Current Thread [Next in Thread]