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.

Note<br />

Capitolo 19. Espressioni Regolari<br />

<strong>Bash</strong> esegue l’espanione del nome del file sugli argomenti passati da riga <strong>di</strong> comando senza il quoting. Il<br />

comando echo <strong>di</strong>mostra questa funzionalità.<br />

bash$ echo *<br />

a.1 b.1 c.1 t2.sh test1.txt<br />

bash$ echo t*<br />

t2.sh test1.txt<br />

Nota: È possibile mo<strong>di</strong>ficare il modo in cui <strong>Bash</strong> interpreta i caratteri speciali nel globbing. Il<br />

comando set -f <strong>di</strong>sabilita il globbing e shopt, con le opzioni nocaseglob e nullglob, ne cambia il<br />

comportamento.<br />

Ve<strong>di</strong> anche Esempio 10-4.<br />

1. Poiché sed, awk e grep elaborano le righe, <strong>di</strong> solito non dovrebbe presentarsi la necessità <strong>di</strong> verificare<br />

un ritorno a capo. In quei casi in cui dovesse esserci un ritorno a capo, perché inserito in una<br />

espressione su più righe, il punto lo verifica.<br />

#!/bin/bash<br />

sed -e ’N;s/.*/[&]/’

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

Saved successfully!

Ooh no, something went wrong!