Changing output file name dynamically using \o

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • temuchin
    New Member
    • Mar 2010
    • 1

    Changing output file name dynamically using \o

    Hi

    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?

    Thanks
  • rski
    Recognized Expert Contributor
    • Dec 2006
    • 700

    #2
    Can't you use option -o instead of \o when you call psql client, because you use psql client dont' you?
    Code:
    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.

    Comment

    Working...