If you are happy to hard-code the list of tables, but just want each of them to be in a different file, you can use the script loop to run the pg_dump several times, substituting the name of each loop in the table:
for table in table1 table2 table3 etc; do pg_dump -t $table -U userName dbName > /home/anik/psqlTest/db_dump_dir/$table.sql; done;
EDIT . This approach can be expanded to dynamically obtain a list of tables by running a query through psql and submitting the results in a loop, rather than as hard code:
for table in $(psql -U userName -d dbName -t -c "Select table_name From information_schema.tables Where table_type='BASE TABLE' and table_name like 'thr_%'"); do pg_dump -t $table -U userName dbName > /home/anik/psqlTest/db_dump_dir/$table.sql; done;
Here psql -t -c "SQL" runs SQL and displays the results without a header or footer; since only one column is selected, each line of the output file written using $(command) will have a table name, and your shell will cycle through them one at a time.
IMSoP
source share