Data can be exported using copy command or by taking use of command line options of psql command.

To Export csv data from table user to csv file:

psql -p \\<port> -U \\<username> -d \\<database> -A -F<delimiter> -c\\<sql to execute> \\> \\<output filename with path>

psql -p 5432 -U postgres -d test_database -A -F, -c "select * from user" > /home/user/user_data.csv

Here combination of -A and -F does the trick.

-F is to specify delimiter

-A or --no-align

Switches to unaligned output mode. (The default output mode is otherwise aligned.)