miércoles, 26 de febrero de 2014

calculo de dias

#! /bin/bash
clear

echo "Introduzca un Dia:"
read d
echo "Introduce un Mes:"
read m
echo "Introduce un Anyo:"
read a

cal $m $a

if [ $d -lt 10 ]
then
        lu=$(cal $m $a | tail -6 | cut -c4-5 | grep " $d")
        ma=$(cal $m $a | tail -6 | cut -c7-8 | grep " $d")
        mi=$(cal $m $a | tail -6 | cut -c10-11 | grep " $d") #revisar la fecha con el anio
        ju=$(cal $m $a | tail -6 | cut -c13-14 | grep " $d") #no muestra el resto de dias de la semana
        vi=$(cal $m $a | tail -6 | cut -c16-17 | grep " $d")
        sa=$(cal $m $a | tail -6 | cut -c19-20 | grep " $d")
        dom=$(cal $m $a | tail -6 | cut -c1-2 | grep " $d")

        echo ""

        if [ ! -z $lu ]
        then
                echo "  **********"
                echo "  *Es lunes*"
                echo "  **********"
                echo ""
        fi

        if [ ! -z $ma ]
        then
                echo "  ***********"
                echo "  *Es martes*"
                echo "  ***********"
                echo ""
        fi

        if [ ! -z $mi ]
        then
                echo "  **************"
                echo "  *Es miercoles*"
                echo "  **************"
                echo ""
        fi

        if [ ! -z $ju ]
        then
                echo "  ***********"
                echo "  *Es jueves*"
                echo "  ***********"
                echo ""
        fi

        if [ ! -z $vi ]
        then
                echo "  ************"
                echo "  *Es viernes*"
                echo "  ************"
                echo ""
        fi

        if [ ! -z $sa ]
        then
                echo "  ***********"
                echo "  *Es sabado*"
                echo "  ***********"
                echo ""
        fi

        if [ ! -z $dom ]
        then
                echo "  ************"
                echo "  *Es domingo*"
                echo "  ************"
                echo ""
        fi

else

        lu=$(cal $m $a | tail -6 | cut -c4-5 | grep $d)
        ma=$(cal $m $a | tail -6 | cut -c7-8 | grep $d)
        mi=$(cal $m $a | tail -6 | cut -c10-11 | grep $d)
        ju=$(cal $m $a | tail -6 | cut -c13-14 | grep $d)
        vi=$(cal $m $a | tail -6 | cut -c16-17 | grep $d)
        sa=$(cal $m $a | tail -6 | cut -c19-20 | grep $d)
        dom=$(cal $m $a | tail -6 | cut -c1-2 | grep $d)

         echo ""

        if [ ! -z $lu ]
        then
                echo "  **********"
                echo "  *Es lunes*"
                echo "  **********"
                echo ""
        fi

        if [ ! -z $ma ]
        then
                echo "  ***********"
                echo "  *Es martes*"
                echo "  ***********"
                echo ""
        fi

        if [ ! -z $mi ]
        then
                echo "  **************"
                echo "  *Es miercoles*"
                echo "  **************"
                echo ""
        fi

        if [ ! -z $ju ]
        then
                echo "  ***********"
                echo "  *Es jueves*"
                echo "  ***********"
                echo ""
        fi

        if [ ! -z $vi ]
        then
                echo "  ************"
                echo "  *Es viernes*"
                echo "  ************"
                echo ""
        fi

        if [ ! -z $sa ]
        then
                echo "  ***********"
                echo "  *Es sabado*"
                echo "  ***********"
                echo ""
        fi

        if [ ! -z $dom ]
        then
                echo "  ************"
                echo "  *Es domingo*"
                echo "  ************"
                echo ""
        fi


fi

No hay comentarios:

Publicar un comentario