Son una bola de retrasados haciendo pings de la muerte, se ponen de acuerdo para hacerlo todos al mismo tiempo
1... 2 ... 3... [ENTER]
Y listo!
1... 2 ... 3... [ENTER]
Y listo!
![:P :P](https://forum.elhacker.net/Smileys/navidad/tongue.gif)
Esta sección te permite ver todos los mensajes escritos por este usuario. Ten en cuenta que sólo puedes ver los mensajes escritos en zonas a las que tienes acceso en este momento.
Mostrar Mensajes Menú#!/bin/bash
#===============================================================================
#
# FILE: todo.sh
#
# USAGE: ./todo.sh OPTIONS
#
# DESCRIPTION: TODO List, nos permite hacer anotaciones sobre acciones que haremos en un futuro.
#
# OPTIONS: ./todo -h|H
# REQUIREMENTS: ---
# BUGS: ---
# NOTES: ---
# AUTHOR: Leo Gutiérrez R. (), leorocko13@hotmail.com | leogutierrez@elhacker.net
# COMPANY:
# CREATED: 13/06/11 16:45:05 MDT
# REVISION: ---
#===============================================================================
FILE=~/.todo/todo
source functions
# Checar que exista la carpeta y archivo de lista.
[ ! -d ~/.todo ] && {
ask "No existe la carpeta, desea crearla ?" && {
mkdir ~/.todo
echo -e "Creando archivo \"todo\" en ~/.todo";
touch ~/.todo/todo
} || {
echo -e "Saliendo . . .";
exit 0
}
}
[ $# = 0 ] && usage;
while getopts "hHr:R:lLn:N:d:D:be:E:g:G:kKs:S:qQ" OPTION
do
case $OPTION in
h|H)
usage
exit 1
;;
n|N)
TEST=$OPTARG
# Actualizar el archivo :
updateList;
#echo -e "Opción n, valor : ${TEST}";
echo -e "$(tput bold)$(tput setaf 2)TODO : [$[ $(cat $FILE | wc -l) + 1 ]] ${TEST}";
echo -e "[$[ $(cat $FILE | wc -l) + 1 ]] ${TEST}" >> $FILE
tput sgr0;
exit 0;
;;
g|G)
(( $OPTARG > $(cat $FILE | wc -l) )) && {
echo -e "$(tput bold)$(tput setaf 1)ERROR, tarea inexistente, consulte las tareas con -L ó -l"
tput sgr0;
exit 1;
}
read -p "Texto : " texto
sed -i "${OPTARG}s/^\(.*\)$/\1 $texto/g" $FILE
updateList;
exit 0;
;;
d|D)
# Cercionarnos que elija una TODO hecha.
(( $OPTARG > $(cat $FILE | wc -l) )) && {
echo -e "$(tput bold)$(tput setaf 1)ERROR, tarea inexistente, consulte las tareas con -L ó -l"
tput sgr0;
exit 1;
}
sed -i "${OPTARG}d" $FILE
updateList;
exit 0;
;;
k|K)
[ ! -e ~/.todo/todo ] && {
echo -e "$(tput bold)$(tput setaf 1)No existe el archivo \"todo\" en ~/.todo/";
ask "Desea crearlo? " && {
touch $FILE
}
tput sgr0;
exit 1;
}
cp $FILE ${FILE}.bkp
echo -e "\n$(tput bold)$(tput setaf 1)Archivo de respaldo creado\n";
tput sgr0;
exit 0;
;;
r|R)
(( $OPTARG > $(cat $FILE | wc -l) )) && {
echo -e "$(tput bold)$(tput setaf 1)ERROR, tarea inexistente, consulte las tareas con -L ó -l"
tput sgr0;
exit 1;
}
read -p "Texto : " texto
# Detectar status
sed -n "${OPTARG}p" $FILE | grep "^\[.*\] \[.*\] " &> /dev/null && {
sed -i "2s/.*\(\[.*\]\)\s\(\[.*\]\)\s\(.*\)/\1 \2 $texto/g" $FILE
} || {
sed -i "${OPTARG}s/.*\(\[.*\]\)\s\(.*\)/\1 $texto/g" $FILE
}
updateList;
exit 0;
;;
# -lL Mostrar, listar tareas.
l|L)
(( $(cat $FILE | wc -l) == 0 )) && {
echo -e "$(tput bold)$(tput setaf 1)TODO List vacía, agregue nuevas tareas.";
tput sgr0;
exit 0;
}
updateList;
while read line
do
echo -e "$(tput bold)$(tput setaf 1)${line}";
done < $FILE
tput sgr0;
exit 0;
;;
b|B)
ask "$(tput bold)$(tput setaf 1)Esto borrará todas las tareas, desea continuar? " && {
sed -i '1,$d' $FILE
}
tput sgr0;
exit 0;
;;
q|Q)
sed -i "/\[Hecho\]/d" $FILE
updateList;
exit 0;
;;
s|S)
(( $(cat $FILE | wc -l) == 0 )) && {
echo -e "$(tput bold)$(tput setaf 1)TODO List vacía, agregue nuevas tareas.";
tput sgr0;
exit 0;
}
read -p "Estado de tarea : " status
sed -n "${OPTARG}p" $FILE | grep "^\[.*\] \[.*\] " &> /dev/null && {
sed -i "${OPTARG}s/.*\(\[.*\]\)\s\(\[.*\]\)\s\(.*\)/\1 [$status] \3/g" $FILE
} || {
sed -i "${OPTARG}s/^\(\[.*\]\)\s\(.*\)$/\1 [$status] \2/g" $FILE
}
;;
?)
usage
exit
;;
esac
done
#!/bin/bash
#===============================================================================
#
# FILE: todo.sh
#
# USAGE: ./todo.sh OPTIONS
#
# DESCRIPTION: TODO List, nos permite hacer anotaciones sobre acciones que haremos en un futuro.
#
# OPTIONS: ./todo -h|H
# REQUIREMENTS: ---
# BUGS: ---
# NOTES: ---
# AUTHOR: Leo Gutiérrez R. (), leorocko13@hotmail.com | leogutierrez@elhacker.net
# COMPANY:
# CREATED: 13/06/11 16:45:05 MDT
# REVISION: ---
#===============================================================================
FILE=~/.todo/todo
source functions
# Checar que exista la carpeta y archivo de lista.
[ ! -d ~/.todo ] && {
ask "No existe la carpeta, desea crearla ?" && {
mkdir ~/.todo
echo -e "Creando archivo \"todo\" en ~/.todo";
touch ~/.todo/todo
} || {
echo -e "Saliendo . . .";
exit 0
}
}
[ $# = 0 ] && usage;
while getopts "hHr:R:lLn:N:d:D:be:E:g:G:kKs:S:" OPTION
do
case $OPTION in
h|H)
usage
exit 1
;;
n|N)
TEST=$OPTARG
# Actualizar el archivo :
updateList;
#echo -e "Opción n, valor : ${TEST}";
echo -e "$(tput bold)$(tput setaf 2)TODO : [$[ $(cat $FILE | wc -l) + 1 ]] ${TEST}";
echo -e "[$[ $(cat $FILE | wc -l) + 1 ]] ${TEST}" >> $FILE
tput sgr0;
exit 0;
;;
g|G)
(( $OPTARG > $(cat $FILE | wc -l) )) && {
echo -e "$(tput bold)$(tput setaf 1)ERROR, tarea inexistente, consulte las tareas con -L ó -l"
tput sgr0;
exit 1;
}
read -p "Texto : " texto
sed -i "${OPTARG}s/^\(.*\)$/\1 $texto/g" $FILE
updateList;
exit 0;
;;
d|D)
# Cercionarnos que elija una TODO hecha.
(( $OPTARG > $(cat $FILE | wc -l) )) && {
echo -e "$(tput bold)$(tput setaf 1)ERROR, tarea inexistente, consulte las tareas con -L ó -l"
tput sgr0;
exit 1;
}
sed -i "${OPTARG}d" $FILE
updateList;
exit 0;
;;
k|K)
[ ! -e ~/.todo/todo ] && {
echo -e "$(tput bold)$(tput setaf 1)No existe el archivo \"todo\" en ~/.todo/";
ask "Desea crearlo? " && {
touch $FILE
}
tput sgr0;
exit 1;
}
cp $FILE ${FILE}.bkp
echo -e "\n$(tput bold)$(tput setaf 1)Archivo de respaldo creado\n";
tput sgr0;
exit 0;
;;
r|R)
(( $OPTARG > $(cat $FILE | wc -l) )) && {
echo -e "$(tput bold)$(tput setaf 1)ERROR, tarea inexistente, consulte las tareas con -L ó -l"
tput sgr0;
exit 1;
}
read -p "Texto : " texto
# Detectar status
sed -n "${OPTARG}p" $FILE | grep "^\[.*\] \[.*\] " &> /dev/null && {
sed -i "2s/.*\(\[.*\]\)\s\(\[.*\]\)\s\(.*\)/\1 \2 $texto/g" $FILE
} || {
sed -i "${OPTARG}s/.*\(\[.*\]\)\s\(.*\)/\1 $texto/g" $FILE
}
updateList;
exit 0;
;;
# -lL Mostrar, listar tareas.
l|L)
(( $(cat $FILE | wc -l) == 0 )) && {
echo -e "$(tput bold)$(tput setaf 1)TODO List vacía, agregue nuevas tareas.";
tput sgr0;
exit 0;
}
updateList;
while read line
do
echo -e "$(tput bold)$(tput setaf 1)${line}";
done < $FILE
tput sgr0;
exit 0;
;;
b|B)
ask "$(tput bold)$(tput setaf 1)Esto borrará todas las tareas, desea continuar? " && {
sed -i '1,$d' $FILE
}
tput sgr0;
exit 0;
;;
s|S)
(( $(cat $FILE | wc -l) == 0 )) && {
echo -e "$(tput bold)$(tput setaf 1)TODO List vacía, agregue nuevas tareas.";
tput sgr0;
exit 0;
}
read -p "Estado de tarea : " status
sed -n "${OPTARG}p" $FILE | grep "^\[.*\] \[.*\] " &> /dev/null && {
sed -i "${OPTARG}s/.*\(\[.*\]\)\s\(\[.*\]\)\s\(.*\)/\1 [$status] \3/g" $FILE
} || {
sed -i "${OPTARG}s/^\(\[.*\]\)\s\(.*\)$/\1 [$status] \2/g" $FILE
}
;;
?)
usage
exit
;;
esac
done
function usage()
{
tput bold
tput setaf 6
cat << EOF
Uso: $0 options
TODO List v1.0 | leorocko13@hotmail.com
OPTIONS:
-h|H Muestra este mensaje
-n|N [#TAREA] Nueva tarea
-l|L Listar tareas
-d|D [#TAREA] Eliminar tarea
-r|R [#TAREA] Reemplazar tarea
-b|B Borrar todas las tareas
-g|G [#TAREA] Agregar a una tarea
-k|K Crear respaldo de tareas
-s|S [#TAREA] Agregar estado de la tarea
EOF
tput sgr0;
}
function ask()
{
echo -n "$@" '[y/n] ';
read ans;
case "$ans" in
y*|Y*)
return 0 ;;
*)
return 1 ;;
esac
}
# Detectar status
# sed -n "${OPTARG}p" $FILE | grep "^\[.*\] \[.*\] " &> /dev/null && {
# sed -i "2s/.*\(\[.*\]\)\s\(\[.*\]\)\s\(.*\)/\1 \2 $texto/g" $FILE
# } || {
# sed -i "${OPTARG}s/.*\(\[.*\]\)\s\(.*\)/\1 $texto/g" $FILE
# }
function updateList()
{
rm -f /tmp/todo_temp
# Checamos si la lista no está vacía.
(( $(cat $FILE | wc -l) == 0 )) && {
return;
}
((contador = 1));
while read line
do
echo -e "$line" | grep "^\[.*\] \[.*\] " &> /dev/null && {
echo -e "[$contador] $(echo -e "$line" | sed "s/^\(\[.*\]\)\s\(\[.*\]\)\s\(.*\)/\2 \3/g")" >> /tmp/todo_temp
} || {
echo -e "[$contador] $(echo -e "$line" | sed "s/^\(\[.*\]\)\s\(.*\)/\2/g")" >> /tmp/todo_temp
}
((contador++));
done < $FILE
cp /tmp/todo_temp $FILE
}