How to set tab delimiter using psql -F

In Unix, you can also type

ctrl-V tab

ctrl-V tells the terminal not to interpret the next key.

This also works with carriage returns (^M) and many other special keys like arrow keys


In case if somebody looked for how to do it in the interactive shell: \f '\t'


I think you just need to use a literal tab. How this works depends on your shell. Have you seen this post?

In the bash shell you can do this with $'\t'.

Using the example in your question:

psql -Umyuser mydb -AF $'\t' --no-align -c "select * from mytable" -o /tmp/dumpfile.txt

From man bash:

Words of the form $'string' are treated specially. The word expands to string, with backslash-escaped characters replaced as specified by the ANSI C standard. [...] The expanded result is single-quoted, as if the dollar sign had not been present.

Tags:

Postgresql