Shell script: Dump mysql tables with prefix

Was in need to dump tables with certain prefix with via shell. I used this script:

# Replace DBNAME, USERNAME, PASSWORD with your values.
echo Tell me the prefix.
read prae
test=`mysql -u USERNAME --password=PASSWORD $db --execute="SHOW TABLES LIKE '$prae%'"`
# the test string produces undesirable output at the beginning, the following lines of code extract them, not elegant, but works.
l=`expr length $db`
m=`expr length $prae`
echo Tables: $test3
mysqldump -u USERNAME --password=PASSWORD --opt --databases $db --tables $test3 > ${prae}.sql
echo Data saved.

Did this on MYSQL 5.0.45.