It is necessary in the bash script to check whether the specified psql database exists or not. Are there any regular funds?
For files there is a construction: if [ -f $FILE ]; then if [ -f $FILE ]; then For psql - maybe there is something of their own. Or maybe you should dig in the direction of the physical search for the database itself in the file format?