hervasiop12345

bisiesto

Aug 12th, 2011
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.34 KB | None | 0 0
  1. #!/bin/bash
  2. #
  3. #Description: Recibe un año como parámetro y devuelve 0 si es bisiesto o -1 si no lo es
  4. #
  5. #Author:jMa
  6. #
  7. echo $1 | grep -x -q "[0-9]\+"
  8. num=$?
  9.  
  10. if [ $num != 0 ]
  11. then
  12.   echo "Introduce un año correcto"
  13.   exit -1
  14. fi  
  15.    if [ `cal 2 $1| grep "29" | wc -c` -gt 0 ]
  16.    then  
  17.      exit 0
  18.    else
  19.      exit -1
  20.    fi
  21. fi
Advertisement
Add Comment
Please, Sign In to add comment