xxxxxxxxxx
INPUT='someletters_12345_moreleters.ext'
SUBSTRING=$(echo $INPUT| cut -d'_' -f 2)
echo $SUBSTRING
xxxxxxxxxx
STR="birthday-091216-pics"
SUBSTR=$(echo $STR | cut -d'-' -f 2)
echo $SUBSTR
If a is constant, the following parameter expansion performs substring extraction:
xxxxxxxxxx
a="bla ble blo"; b=${a:4:50}; echo "$b"