fon3.sh

Publicado por Fábio Berbert de Paula 13/11/2002

[ Hits: 5.301 ]

Homepage: https://mestrefabio.com

Download fon3.zip




Shell script simples usado para armazenar registros telefônicos em arquivo texto.

  



Esconder código-fonte

#!/bin/bash
#Wed Aug 14 2002
#
#fon3.sh 
#Escrito em um Red Hat 7.x 
#Ferramente simples, de facil uso e leve para armazenar 
#numeros de telefone.
#
# LINUX: Quem disse que tem que ser facil ???
#
#Greetz: F-117; Dark[x]; anubssys; k1ll3r
#Coded by Carlos Carvalho 
#h4sh@uol.com.br
#www.vivaolinux.com.br

help ()
{
echo
echo
echo
echo
echo
echo -e $"\{FONTE}33[1;31m"
echo "#########################################################################"
echo "#                      fon3.sh    By hash                               #"
echo "#                       h4sh@uol.com.br                                 #"
echo "#########################################################################"
echo "# Usage:                                                                #"
echo "#./fon3.sh                                                              #"
echo "#./fon3.sh { -see [name] | -del [name] | -count                         #"
echo "#            -clearall | -help | -uninstall }                           #"
echo "# Examples:                                                             #"
echo "#        ./fon3.sh (modo interativo)                                    #"
echo "#        ./fon3.sh -see - (mostra todas as entradas)                    #"
echo "#        ./fon3.sh -see nome (mostra entradas do respectivo nome)       #"
echo "#        ./fon3.sh -del nome (deleta entradas do respectivo nome)       #"
echo "#        ./fon3.sh -count (faz a contagem do total de entradas)         #"
echo "#        ./fon3.sh -help (mostra essa mensagem)                         #"
echo "#        ./fon3.sh -clearall (deleta todas as entradas duh! :] )        #"
echo "#        ./fon3.sh -uninstall (desistala o programa)                    #"
echo "#########################################################################"
echo -e $"\{FONTE}33[0;39m"
echo
echo
echo
echo
}

#Edite as duas linhas seguintes se voce preferir 
#outras localizacoes para os arquivos

FONE=~/fonefacil/fone.txt
TELEFONE=~/fonefacil

if [ ! -d $TELEFONE ]; then
mkdir $TELEFONE  
touch $FONE  
fi

while [ -z "$1" ]
do

echo "Entre com um nome ou digite \"fim\" para sair"
read name
        if [ "$name" = "fim" ]; then
                        echo "Tchau!"
                        exit 0
        fi
echo "Numero:"
read number
NUM=$number
NAM=$name
echo "$NAM  --> $NUM" >> $FONE

done

case $1 
in
    -clearall)
                      > $FONE
                                exit 0
                      ;;
         -see)
                     ISTHERE=$(cat $FONE |grep $2) 
                if [ "$?" = 0 ]; then
                 echo "$ISTHERE"
                else
                        echo "NAO encontrado!"
                 exit 1
                fi
                     exit 0
                     ;;
       -count)
                echo "Total:"
                     wc -l $FONE
                     exit 0
                     ;;
         -del)
                     grep -v "$2" $FONE > /tmp/fone
                     > $FONE
                     mv /tmp/fone $FONE
                     exit 0
                     ;;
   -uninstall)
                echo "Tem certeza?? (s/n)"
                read KILL
                if [ "$KILL" != "s" ]; then
            echo "Arquivos inalterados!"
                 exit 0
                fi
                     echo "Removendo arquivos..."
                     rm -rf $TELEFONE
                     if [ ! -d $TELEFONE ]; then
                      echo "Done         [OK]"
            echo "Autoremocao do script!"
            rm -rf $0
                     else
                      echo "Nao foi possivel remover arquivos"
                      exit 1
                     fi
                     exit 0
                     ;;
        -help) 
                help
                exit 0
                ;;
            *)
                     help
                     exit 0
                      ;;
esac

Scripts recomendados

Enviando faixas tocadas no Amarok 2 para o Twitter

backup

Automatiza a instalação do necessário no Debian 8

Firewall Básico e Rápido

Script Admin PDC


  

Comentários

Nenhum comentário foi encontrado.


Contribuir com comentário




Patrocínio

Site hospedado pelo provedor RedeHost.
Linux banner

Destaques

Artigos

Dicas

Tópicos

Top 10 do mês

Scripts