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: Julio C. Neves
Subject: Re: [shell-script] função extract
Date: Wed, 4 Feb 2009 13:13:42 -0200

Ou então:
#!/bin/bash

extract(){
for file in "$@"
do
    if [ -f "$file" ]
    then
        case "$file" in
            *.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'...";;
        esac || echo Arquivo $file corrompido
    else
        echo "'$file' não é um arquivo válido"
    fi
done
}
-- 
Abração,
*Julio
Cursos de Shell e Zenity nos finais de semana:
- Em SP ligue (11) 2125-4747;
- Em DF ligue (61) 3223-3000;
- No RJ brevemente;
- Turmas fechadas em outras cidades ligue (21) 8112-9988*


2009/2/3 Reinaldo de Carvalho <address@hidden>

>   2009/2/3 Guilherme Gall <address@hidden <gmgall%40gmail.com>>:
>
> > 2009/2/3 voyeg3r <address@hidden <voyeg3r%40yahoo.com.br>>:
> >
> > #!/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
>  
>


[As partes desta mensagem que não continham texto foram removidas]



reply via email to

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