Say I have the files:
file1.sql
file2.sql
file3.sql
I need all three files to be executed in a single transaction. I\'m looking for a bash
Either use a sub-shell:
#!/bin/sh
(echo "BEGIN;"; cat file1.sql; cat file2.sql; echo "COMMIT;") \
| psql -U the_user the_database
#eof
or use a here-document:
#!/bin/sh
psql -U the_user the_database <
NOTE: in HERE-documents there will be no globbing, so file*sql will not be expanded. Shell-variables will be expanded, even within quotes.