Advertisement
andmalv

[Script] ObtenerDigitoVerificadorCedula

Sep 4th, 2016
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.35 KB | None | 0 0
  1. #! /bin/bash
  2. #
  3.  
  4. mult=(2 9 8 7 6 3 4)
  5.  
  6. clear
  7. read -ep $'\n\t CI: ' ci
  8.  
  9. for (( i=0; i < 7; i++ )); do
  10.     n=${ci:${i}:1}
  11.    
  12.     let "n *= ${mult[${i}]}"
  13.    
  14.     let "suma += $n"
  15. done
  16.  
  17. digito=$( echo "scale=1; $suma / 10" | bc | cut -d '.' -f 2 )
  18.  
  19. if [[ $digito -gt 0 ]]; then
  20.     digito=$[ 10 - digito ]
  21. fi
  22.  
  23. echo -e "\n\t D. Verificador: $digito \n"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement