astromonerd
astromonerd

Reputation: 937

How can I use a timestamp to name a gnuplot file?

Is it possible to name my gnuplot out file with the date and time it was created? I currently create files with set names as follows:

     set term post eps color
     set output '/path/dateandtime.eps'
     plot
     set term x11

Upvotes: 4

Views: 1208

Answers (2)

Christoph
Christoph

Reputation: 48390

You can use the builtin function time to get the current timestamp and strftimeto format it:

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

Upvotes: 5

andyras
andyras

Reputation: 15910

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

#!/usr/bin/env gnuplot

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

The . operator concatenates strings.

Upvotes: 3

Related Questions