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.

(( 5 / 4 )) # Divisione o.k.<br />

echo "L’exit status <strong>di</strong> \"(( 5 / 4 ))\" è $?." # 0<br />

Capitolo 7. Verifiche<br />

(( 1 / 2 )) # Risultato della <strong>di</strong>visione /dev/null # Divisione per 0 non consentita.<br />

# ^^^^^^^^^^^<br />

echo "L’exit status <strong>di</strong> \"(( 1 / 0 ))\" è $?." # 1<br />

# Che funzione ha "2>/dev/null"?<br />

# Cosa succederebbe se fosse tolto?<br />

# Toglietelo, quin<strong>di</strong> rieseguite lo script.<br />

exit 0<br />

7.2. Operatori <strong>di</strong> verifica <strong>di</strong> file<br />

-e<br />

-a<br />

-f<br />

-s<br />

-d<br />

-b<br />

-c<br />

Restituiscono vero se...<br />

il file esiste<br />

il file esiste<br />

Effetto identico a -e, ma è stato “deprecato” e scoraggiato l’utilizzo.<br />

il file è un file regolare (non una <strong>di</strong>rectory o un file <strong>di</strong> <strong>di</strong>spositivo)<br />

il file ha <strong>di</strong>mensione superiore a zero<br />

il file è una <strong>di</strong>rectory<br />

il file è un <strong>di</strong>spositivo a blocchi (floppy, cdrom, ecc.)<br />

il file è un <strong>di</strong>spositivo a caratteri (tastiera, modem, scheda au<strong>di</strong>o, ecc.)<br />

70

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

Saved successfully!

Ooh no, something went wrong!