Bash function for postgres