By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,731 Members | 1,104 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,731 IT Pros & Developers. It's quick & easy.

Changing output file name dynamically using \o

P: 1

I'm using the option \o to put the query output into a file. This task is scheduled to run every night.

Is there a way to automatically put the current date at the end of the name of each file?

Mar 30 '10 #1
Share this Question
Share on Google+
1 Reply

Expert 100+
P: 700
Can't you use option -o instead of \o when you call psql client, because you use psql client dont' you?
Expand|Select|Wrap|Line Numbers
  1. psql -o "file-`date`"
and everything would be put into file called file-<current date>
Or you can try to edit command.c file in <postgres source directory>bin/psql/
and here in the if statement where '\o' is processing add some <date> at the end of fielname (it is called fname here i guess), but it will be global and I don't know if you want that setting for every \o option.
Mar 31 '10 #2

Post your reply

Sign in to post your reply or Sign up for a free account.