[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: RES: [shell-script] Trabalhando com vetores e combinações em shell s
From: |
Thobias Salazar Trevisan |
Subject: |
Re: RES: [shell-script] Trabalhando com vetores e combinações em shell script (fwd) |
Date: |
Tue, 27 May 2003 16:51:20 -0300 (BRT) |
ae rodolfo,
On Tue, 27 May 2003, Rodolfo Villanova wrote:
> Acredito não haver me expressado com clareza, mas preciso montar
> algo semelhante para Korn Shell, que funcione sob Unix True64
> (Compaq/HP) e SunOS.
>
> Os testes que realizei com o excelente exemplo que elaboraste para
> ambiente bash infelizmente não funcionou como esperado naqueles
> ambientes.
hmmm, estou testando este com sh. acho que deve funcionar no seu
ambiente. Percebi que aquela minha solução tinha
algumas incompatibilidades com o sh. E para tirar o od, gawk, fiz
um 'merge' com a solução que o aurelio postou.
Testa esta:
#!/bin/sh
inc_letra ()
{
echo "ABCDEFGHIJKLMNOPQRSTUVWXYZA" | sed "s/.*$1\(.\).*/\\1/"
}
a=`echo $1 | cut -c1`
b=`echo $1 | cut -c2`
n=`echo $1 | cut -c3-4`
n=`expr $n + 1`
if [ $n = 100 ]
then
n=0
if [ "$b" = "Z" ];then
b=A
if [ "$a" = "Z" ];then
a=A
else
a=`inc_letra $a`
fi
else
b=`inc_letra $b`
fi
fi
printf '%c%c%02d\n' $a $b $n
######################################################
testando em um SunOS 5.7.
$ ./x AA00
AA01
$ ./x AA99
AB00
$ ./x AZ99
BA00
$ ./x BZ99
CA00
$ ./x ZZ99
AA00
pelos menos acho que as mudanças, se necessárias, serão menores :)
blz ?
thobias
-------
echo 9446046325380026818553633794429812592304650P | dc
-------
http://www.lcp.coppe.ufrj.br/~thobias
____________________________
|
| Against - HTML Mail
| Against - MS ATTACHMENTS
|
----------------------------
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: RES: [shell-script] Trabalhando com vetores e combinações em shell script (fwd),
Thobias Salazar Trevisan <=