Re: Chulerías para Debian
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Guimi wrote:
> $cat fortunecow.sh
> #!/bin/bash
> #
> # fortunecow 0.1 - GPL
> # (c) Guimi
> # http://guimi.net
> #
>
> # Parametros
> FORTUNE=/usr/games/fortune
> COWSAY="/usr/bin/cowsay -f"
> DIR_VACAS=/usr/share/cowsay/cows/
>
> # Obtenemos el numero de vacas disponibles
> vacas=$(ls $DIR_VACAS | wc -l)
>
> # Elegimos una vaca
> vaca=$RANDOM
> let "vaca %= $vacas"
>
> # Le pedimos a la vaca elegida que nos
> #+ lea la fortuna
> contador=0
> cd $DIR_VACAS
> for x in *.cow
> do
> if [ $contador == $vaca ]
> then
> $FORTUNE | $COWSAY $x
> exit 0
> else
> let "contador += 1"
> fi
> done
>
>
> Saludos
> Güimi
> http://guimi.net
>
>
$ cat fortunecow2.sh
#!/bin/bash
FORTUNE=/usr/games/fortune
COWSAY="/usr/bin/cowsay -f"
DIR_VACAS=/usr/share/cowsay/cows
i=$(( 1 + $RANDOM % $(ls $DIR_VACAS/*.cow | wc -l) ))
$FORTUNE | $COWSAY `ls $DIR_VACAS/*.cow | sed -e ${i}p -e d`
- --
Saludos,
Alejandro Bárcena Campos
When you say "I wrote a program that crashed Windows", people just stare
at you blankly and say "Hey, I got those with the system, *for free*".
-- Linus Torvalds
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFFU3zApZP6bMridNYRAs6zAJ9pEJGXisBBeEyjbrkraItgdMZ80ACeOleU
JbwxNjKbanQC9fqgrzziKZU=
=2mwP
-----END PGP SIGNATURE-----
Reply to: