How to use timestamp for gnuplot file name?

Can my gnuplot out file be called the date and time it was created? I am currently creating files with set names as follows:

     set term post eps color
     set output '/path/dateandtime.eps'
     plot
     set term x11
+4
source share
2 answers

You can use the built-in function timeto get the current timestamp and strftimeto format it:

set output strftime('/path/%F_%H-%M-%S.eps', time(0))
+4
source

You can get output from an external command as a string using the command system:

#!/usr/bin/env gnuplot

date = system("date +%F.%H.%M.%S")
set term ...
set output '/path/'.date.'.eps'
plot

The operator .concatenates strings.

+3
source

All Articles