[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [shell-script] testar uma lista!
From: |
Flavio Torres |
Subject: |
Re: [shell-script] testar uma lista! |
Date: |
Mon, 08 May 2006 19:31:32 -0300 |
User-agent: |
Thunderbird 1.5.0.2 (Windows/20060308) |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Ricardo Acosta escreveu:
> Camaradas, como testar se uma string está em uma lista? estou
> usando o OU lógico, no entanto tenho que repetir por N vezes o
> teste.
Olá, será que isto serve?
linuxuser@backup:~$ cat param
trufa
barra
chiclete
chocolate
limao
linuxuser@backup:~$ echo $PARAM
chocolate
linuxuser@backup:~$ for i in $(cat param);do [ "$PARAM" = "$i" ] &&
echo "ok" || echo "nok";done
nok
nok
nok
ok
nok
linuxuser@backup:~$
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3-cvs (MingW32)
iD8DBQFEX8bDNRQApncg294RArPgAJ9h6iJqchVTBGDg8Tu/hee5Hv4ITACgmC9Y
sbcL8OTtjyxM7zeWBr8S+ro=
=bHFe
-----END PGP SIGNATURE-----