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.

expr substr $stringa $posizione $lunghezza<br />

Estrae $lunghezza caratteri da $stringa iniziando da $posizione.<br />

stringaZ=abcABC123ABCabc<br />

# 123456789......<br />

# L’in<strong>di</strong>cizzazione inizia da 1.<br />

echo ‘expr substr $stringaZ 1 2‘ # ab<br />

echo ‘expr substr $stringaZ 4 3‘ # ABC<br />

expr match "$stringa" ’\($sottostringa\)’<br />

Capitolo 9. Variabili riviste<br />

Estrae $sottostringa dalla parte iniziale <strong>di</strong> $stringa, dove $sottostringa è una<br />

espressione regolare.<br />

expr "$stringa" : ’\($sottostringa\)’<br />

Estrae $sottostringa dalla parte iniziale <strong>di</strong> $stringa, dove $sottostringa è<br />

un’espressione regolare.<br />

stringaZ=abcABC123ABCabc<br />

# =======<br />

echo ‘expr match "$stringaZ" ’\(.[b-c]*[A-Z]..[0-9]\)’‘ # abcABC1<br />

echo ‘expr "$stringaZ" : ’\(.[b-c]*[A-Z]..[0-9]\)’‘ # abcABC1<br />

echo ‘expr "$stringaZ" : ’\(.......\)’‘ # abcABC1<br />

# Tutte le forme precedenti danno lo stesso risultato.<br />

expr match "$stringa" ’.*\($sottostringa\)’<br />

Estrae $sottostringa dalla parte finale <strong>di</strong> $stringa, dove $sottostringa è<br />

un’espressione regolare.<br />

expr "$stringa" : ’.*\($sottostringa\)’<br />

Estrae $sottostringa dalla parte finale <strong>di</strong> $stringa, dove $sottostringa è<br />

un’espressione regolare.<br />

stringaZ=abcABC123ABCabc<br />

# ======<br />

121

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

Saved successfully!

Ooh no, something went wrong!