11.04.2013 Views

Guida avanzata di scripting Bash - Portale Posta DMI

Guida avanzata di scripting Bash - Portale Posta DMI

Guida avanzata di scripting Bash - Portale Posta DMI

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

done<br />

exit 0<br />

Capitolo 7. Verifiche<br />

Ve<strong>di</strong> anche Esempio 28-1, Esempio 10-7, Esempio 10-3, Esempio 28-3 e Esempio A-1 che illustrano gli<br />

utilizzi degli operatori <strong>di</strong> verifica <strong>di</strong> file.<br />

7.3. Altri operatori <strong>di</strong> confronto<br />

-eq<br />

-ne<br />

-gt<br />

-ge<br />

Un operatore <strong>di</strong> verifica binario confronta due variabili o due grandezze. Si faccia attenzione alla<br />

<strong>di</strong>fferenza tra il confronto <strong>di</strong> interi e quello <strong>di</strong> stringhe.<br />

confronto <strong>di</strong> interi<br />

è uguale a<br />

if [ "$a" -eq "$b" ]<br />

è <strong>di</strong>verso (non uguale) da<br />

if [ "$a" -ne "$b" ]<br />

è maggiore <strong>di</strong><br />

if [ "$a" -gt "$b" ]<br />

è maggiore <strong>di</strong> o uguale a<br />

if [ "$a" -ge "$b" ]<br />

74

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!