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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

;<br />

;;<br />

.<br />

.<br />

Anche alcune operazioni <strong>di</strong> ricerca <strong>di</strong> corrispondenza utilizzano il #.<br />

Capitolo 3. Caratteri speciali<br />

Separatore <strong>di</strong> coman<strong>di</strong> [punto e virgola]. Permette <strong>di</strong> inserire due o più coman<strong>di</strong> sulla stessa riga.<br />

echo ehilà; echo ciao<br />

if [ -x "$nomefile" ]; then # Notate che "if" e "then" hanno bisogno del<br />

#+ punto e virgola. Perché?<br />

echo "Il file $nomefile esiste."; cp $nomefile $nomefile.bak<br />

else<br />

echo "$nomefile non trovato."; touch $nomefile<br />

fi; echo "Verifica <strong>di</strong> file completata."<br />

Si faccia attenzione che “;”, talvolta, deve essere preceduto da un carattere <strong>di</strong> escape.<br />

Delimitatore in un’opzione case [doppio punto e virgola].<br />

case "$variabile" in<br />

abc) echo "\$variabile = abc" ;;<br />

xyz) echo "\$variabile = xyz" ;;<br />

esac<br />

Comando “punto” [punto]. Equivale a source (ve<strong>di</strong> Esempio 11-20). È un builtin bash.<br />

“punto”, componente dei nomi dei file. Quando si ha a che fare con i nomi dei file si deve sapere<br />

che il punto è il prefisso dei file “nascosti”, file che un normale comando ls non visualizza.<br />

bash$ touch .file_nascosto<br />

bash$ ls -l<br />

total 10<br />

-rw-r--r-- 1 bozo 4034 Jul 18 22:04 data1.addressbook<br />

12

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

Saved successfully!

Ooh no, something went wrong!