How can i do line breaks properly in bash script, the following command works fine without adding line breaks.
for i in {table1,table2,table3}; do psql -U postgres -c "\COPY (SELECT * FROM "DB"."$i") TO "$i".csv DELIMITER ',' CSV"; done
however i would like add to more table names in the script, i keep getting (Filename too long) error. I want to do something like the following,
for i in {table1, \
table2, \
table3}; do psql -U postgres -c "\COPY (SELECT * FROM "DB"."$i") TO "$i".csv
DELIMITER ',' CSV"; done
But i keep getting ERROR: syntax error at or near "}"
CodePudding user response:
You don't need curly braces {}
to denote an array in bash, just do it like:
for i in table1 \
table2 \
table3; do psql -U postgres -c "\COPY (SELECT * FROM "DB"."$i") TO "$i".csv
DELIMITER ',' CSV"; done