# dbdump-01_06_2017.sql
# dbdump-25_05_2017.sql
# dbdump-31_01_2016.sql
#to get last created file:
dirname=$(ls -dt ../db/dbdump-* | head -1)
echo $dirname
#to get last file by fillename:
dirname=$(ls "$SCRIPTPATH"/../db/dbdump-* | sort -n -t - -k 2 | head -1)
echo $dirname
#-n: sorts numerically
#-t: field separator '-'
#-k: sort on second field, in your case the numbers after the first '-'