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
Refer to answers in below question,
You can write between << EOF and EOF as mentioned in answers.
#!/bin/bash whoami sudo -u someuser bash << EOF echo "In" whoami EOF echo "Out" whoami
How do I use su to execute the rest of the bash script as that user?