hervasiop12345

capicuasinrev

Aug 12th, 2011
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.48 KB | None | 0 0
  1. #!/bin/bash
  2. #
  3. #Description:Recibe un entero positivo y devuelve  0 si es capicĂșa o 1 en caso contrario
  4. #
  5. #Auhor:jMa
  6. #
  7.  
  8. echo $1 | grep -x -q "[0-9]\+"
  9. num=$?
  10. if [ \( $# != 1 \) ] || [ \( $num -eq 1 \) ]
  11. then
  12.   echo "Sintaxis: capicuasinrev enteropositivo"
  13.   exit 2
  14. fi
  15.  
  16. car=$(echo -n $1 | wc -c)
  17. aux=""
  18. for i in `seq $car -1 1`
  19. do
  20.   aux=$(echo $1 | cut -c $i-$i)  
  21.   numinv=$numinv$aux  
  22. done
  23. echo $numinv
  24.  
  25. if [ "$numinv" == "$1" ]
  26. then
  27.   exit 0
  28. else
  29.   exit 1
  30. fi
Advertisement
Add Comment
Please, Sign In to add comment