Thursday, October 23, 2008

Bash ANSI-C quoting

The syntax of ANSI-C quoting is something like
$'\0x009' or $'\t'.

This is useful when you want to input a tab on the command line as an input parameter (tab key is mapped to auto-completion in bash).

for example:
psql -A -F $'\t' ...
will set the field separator to tab.

This is documented in as:
"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. Backslash escape sequences."

For tab, you can also input a CTRL-I (type CTRL-V-I).