$ cat sec.bash
#!/bin/bash
sec="S0000000A9Z";
ad=1;
for s in `seq -w 02 11 | sort -rn`
do
c=`expr substr $sec $s 1`; cc=`printf '%d' "'$c"`;
e=`expr $cc + $ad`; ad=0;
if [ $e -eq 58 ]; then e=65; fi;
if [ $e -eq 91 ]; then e=48; ad=1; fi;
nsec="$(printf "\\$(printf '%03o' $e)")${nsec}"
done
echo -e " $sec \n S$nsec";
$ ./sec.bash
S0000000A9Z
S0000000AA0
No hay comentarios:
Publicar un comentario