Para o bash:
# See "modern regexps" in regex(7) for regexp syntax.
# The intermediate $re variable is not necessary, but it removes the
# need for having to escape every single metacharacter in the regexp.
re='_(Q_[[:digit:]]+)'
if [[ $name =~ $re ]]; then
part=${BASH_REMATCH[1]}
echo "Matched on $part"
else
echo "Match failed"
fi