SCM - Compressão em Massa
Publicado por Slackjeff (última atualização em 28/06/2018)
[ Hits: 1.603 ]
Homepage: https://slackjeff.com.br
Simples compressão em massa (bash, ksh, zsh).
Modo de uso e outras informações:
https://notabug.org/jeffersonrocha/scm/raw/master/README.md
#!/usr/bin/env bash
#=============HEADER================================================|
#AUTOR
#  Jefferson Rocha <lrcjefferson@gmail.com> 
#
#PROGRAM
#  SCM - Simple Compreension Mass
#
#DESC
#
#TESTED SHELLS:
# Bash: version 4.3.48
# Ksh:  version 93u+
# Zsh:  version 5.2
#
#CHANGELOG
#===================================================================|
#=========VARS============================|
#==CONFIGURATIONS
# Create MD5 file?
MD5="0" # 0 OFF | 1 ON
readonly NAME="SCM"
readonly VERSION="0.1"
#==Colors
bold=$(tput bold)
fg_error=$(tput setaf 1)
fg_ok=$(tput setaf 2)
fg_end=$(tput sgr0)
#=========================================|
#=========TESTES==========================|
deps=("gzip" "tar" "md5sum") # program dependencies
for x in "${deps[@]}"; {
    if ! type -p "${x}" 1> /dev/null 2>&1; then
        # MD5 enabled and installed on system?
        if [ "${x}" = "${deps[2]}" ] && [ "$MD5" = "1" ] ; then
            printf "${bold}${fg_error}U NEED INSTALL '${x}' FOR CONTINUE;${fg_end}\n"
            exit 1
        else
            continue
        fi
        printf "${bold}${fg_error}U NEED INSTALL '${x}' FOR CONTINUE;${fg_end}\n"
    fi
}
#=========================================|
#========FUNCTIONS========================|
USAGE(){
cat <<EOH
   USAGE HERE.
EOH
exit 0
}
_COMPRESS(){
# Local variables:
typeset INPUT_TYPE
typeset ARCHIVE
    until [ -z "$1" ]; do # Main loop
        [ -d "$1" ] && INPUT_TYPE="DIRECTORY" || INPUT_TYPE="ARCHIVE"  # Input type.
            [ ! -w "$1" ] && { printf "NO PERMISSION!"; continue ;}    # Have permission write?
            ARCHIVE="${1/%\//}-${INPUT_TYPE}.gz"
            if tar cf - "$1" | gzip -9 > "${ARCHIVE}"; then
               [ "$MD5" = "1" ] && md5sum "${ARCHIVE}" > "${ARCHIVE}.md5" # ON? Generate .md5 file
                printf "${bold}${fg_ok}'${1}'......\t[OK]${fg_end}\n"
            else
                printf "${bold}${fg_error}'${1}......\t[ERROR]'${fg_end}\n"
            fi
            shift # Downnn!
    done
}
#=========================================|
# no params? go function.
[ "$#" = "0" ] && USAGE
#################
# MAINLAND here #
#################
if [ "$1" = "compress" ]; then
    shift # Palmeiras
    if [ -z "$1" ]; then
        USAGE
    else
        _COMPRESS "$@"
    fi
elif [ "$1" = "usage" ] || [ "$1" = "help" ]; then
    USAGE
fi
Localizando tentativas de invasão
Controle de cópia de arquivos por tamanho
Reiniciar modem via Shell Script
Download do LXQT Slackware Current
Nenhum comentário foi encontrado.
IA Turbina o Desktop Linux enquanto distros renovam forças
Como extrair chaves TOTP 2FA a partir de QRCODE (Google Authenticator)
Linux em 2025: Segurança prática para o usuário
Desktop Linux em alta: novos apps, distros e privacidade marcam o sábado
IA chega ao desktop e impulsiona produtividade no mundo Linux
Atualizando o Fedora 42 para 43
Como saber se o seu e-mail já teve a senha vazada?
Como descobrir se a sua senha já foi vazada na internet?
E aí? O Warsaw já está funcionando no Debian 13? [RESOLVIDO] (13)
copiar library para diretorio /usr/share/..... su com Falha na a... (1)
Problema em SSD ao dar boot LinuxMint LMDE FAYE 64 (3)









