So I have some sql in a varible. I could put that in a file and give it to psql as input but I wonder if there is an easy way to do this without the file ?
1 Answer
You can either pipe the command to psql
echo "$some_sql_in_a_varible" | psql -d mydatabase
or use -c
psql -d database -c "$some_sql_in_a_varibl"
Mor info on the psql man page