can I change/su user in the middle of a script?
if [ \"$user\" == \"\" ]; then echo \"Enter the table name\"; read user fi gunzip * chown postgres * su pos
You can, but bash won't run the subsequent commands as postgres. Instead, do:
su postgres -c 'dropdb $user'
The -c flag runs a command as the user (see man su).
-c
man su