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.

exit 0<br />

Capitolo 10. Cicli ed alternative<br />

Vi è una sintassi alternativa per il ciclo for che risulta molto familiare ai programmatori in<br />

linguaggio C. Si basa sull’uso del costrutto doppie parentesi.<br />

Esempio 10-12. Un ciclo for in stile C<br />

#!/bin/bash<br />

# Due mo<strong>di</strong> per contare fino a 10.<br />

echo<br />

# Sintassi standard.<br />

for a in 1 2 3 4 5 6 7 8 9 10<br />

do<br />

echo -n "$a "<br />

done<br />

echo; echo<br />

#<br />

+===================================================================+<br />

# Ora facciamo la stessa cosa usando la sintassi in stile C.<br />

LIMITE=10<br />

for ((a=1; a

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

Saved successfully!

Ooh no, something went wrong!