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.

Capitolo 33. Miscellanea<br />

Nota: Di solito è consigliabile impostare l’attributo <strong>di</strong> grassetto per il testo colorato in primo piano.<br />

tput sgr0 ripristina il terminale alle normali impostazioni. Se viene omesso, tutti i successivi output, su<br />

quel particolare terminale, rimarranno blu.<br />

Nota: Poiché tput sgr0, in certe circostanze, fallisce nel ripristinare le precedenti impostazioni, echo<br />

-ne \E[0m potrebbe rivelarsi una scelta migliore.<br />

Si utilizzi il seguente schema per scrivere del testo colorato su uno sfondo altrettanto<br />

colorato.<br />

echo -e ’\E[COLORE1;COLORE2mQui va inserito il testo.’<br />

“\E[” da inizio alla sequenza <strong>di</strong> escape. I numeri corrispondenti a “COLORE1” e<br />

“COLORE2”, separati dal punto e virgola, specificano i colori <strong>di</strong> primo piano e dello<br />

sfondo, secondo i valori in<strong>di</strong>cati nella tabella riportata più sotto. (L’or<strong>di</strong>ne dei numeri non è<br />

importante perché quelli per il primo piano cadono in un intervallo che non si sovrappone a<br />

quello dei numeri dello sfondo.) “m” termina la sequenza <strong>di</strong> escape ed il testo deve<br />

incominciare imme<strong>di</strong>atamente dopo.<br />

Si noti che tutta la sequenza <strong>di</strong> escape che viene dopo echo -e va racchiusa tra apici singoli.<br />

I numeri della seguente tabella valgono per un terminale rxvt. I risultati potrebbero variare su altri<br />

emulatori <strong>di</strong> terminale.<br />

Tabella 33-1. Numeri che rappresentano i colori nelle sequenze <strong>di</strong> escape<br />

Colore Primo piano Sfondo<br />

nero 30 40<br />

rosso 31 41<br />

verde 32 42<br />

giallo 33 43<br />

blu 34 44<br />

magenta 35 45<br />

cyan 36 46<br />

bianco 37 47<br />

561

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

Saved successfully!

Ooh no, something went wrong!