Tôi có thể thay đổi/su người dùng ở giữa tập lệnh không?Tôi có thể chạy 'su' ở giữa tập lệnh bash không?
if [ "$user" == "" ]; then
echo "Enter the table name";
read user
fi
gunzip *
chown postgres *
su postgres
dropdb $user
psql -c "create database $user with encoding 'unicode';" -U dbname template1
psql -d $user -f *.sql
thể trùng lặp của [Làm thế nào để sử dụng su để thực hiện phần còn lại của kịch bản bash là người dùng đó?] (Http://stackoverflow.com/questions/1988249/how-do- i-use-su-to-execute-the-rest-of-the-bash-script-as-that-user) –