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.

Note<br />

Esempio 4-7. Uso <strong>di</strong> shift<br />

Capitolo 4. Introduzione alle variabili ed ai parametri<br />

#!/bin/bash<br />

# Utilizzo <strong>di</strong> ’shift’ per elaborare tutti i parametri posizionali.<br />

# Chiamate lo script shft ed invocatelo con alcuni parametri, per esempio<br />

# ./shft a b c def 23 skidoo<br />

until [ -z "$1" ] # Finché ci sono parametri...<br />

do<br />

echo -n "$1 "<br />

shift<br />

done<br />

echo # Linea extra.<br />

exit 0<br />

Nota: Il comando shift agisce allo stesso modo sui parametri passati ad una funzione. Ve<strong>di</strong><br />

Esempio 33-15.<br />

1. È il processo che chiama lo script che imposta il parametro $0. Per convenzione, questo parametro è<br />

il nome dello script. Ve<strong>di</strong> la pagina <strong>di</strong> manuale <strong>di</strong> execv.<br />

48

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

Saved successfully!

Ooh no, something went wrong!