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.

Cautela<br />

Con alcuni coman<strong>di</strong> e utility, come echo e sed, l’escaping <strong>di</strong> un carattere potrebbe<br />

avere un effetto particolare - quello <strong>di</strong> attribuire un significato specifico a quel<br />

carattere (le c.d. sequenze <strong>di</strong> escape [N.d.T.]).<br />

Capitolo 5. Quoting<br />

Significati speciali <strong>di</strong> alcuni caratteri preceduti da quello <strong>di</strong> escape:<br />

Da usare con echo e sed<br />

\n<br />

\r<br />

\t<br />

\v<br />

\b<br />

\a<br />

\0xx<br />

significa a capo<br />

significa invio<br />

significa tabulazione<br />

significa tabulazione verticale<br />

significa ritorno (backspace)<br />

“significa allerta” (segnale acustico o accensione <strong>di</strong> un led)<br />

trasforma in carattere ASCII il valore ottale 0xx<br />

Esempio 5-2. Sequenze <strong>di</strong> escape<br />

#!/bin/bash<br />

# escaped.sh: sequenze <strong>di</strong> escape<br />

echo; echo<br />

echo "\v\v\v\v" # Visualizza letteralmente: \v\v\v\v .<br />

# Utilizzate l’opzione -e con ’echo’ per un corretto impiego delle<br />

#+ sequenze <strong>di</strong> escape.<br />

echo "============="<br />

echo "TABULAZIONE VERTICALE"<br />

echo -e "\v\v\v\v" # Esegue 4 tabulazioni verticali.<br />

echo "=============="<br />

52

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

Saved successfully!

Ooh no, something went wrong!