Skip to content
Advertisement

Add timestamp to R CMD BATCH outfile name

I want to run a script, and name the outfile. The default looks like this:

R CMD BATCH $HOME/test.R $HOME/runoutput/test_

How do I add a timestamp to the name?

Something like this:

R CMD BATCH $HOME/test.R $HOME/runoutput/test_$(date +"%F_%H_%M_%S")

Advertisement

Answer

Couldn’t show backticks in the comments, see below:

R CMD BATCH $HOME/test.R $HOME/runoutput/test_`date +"%F_%H_%M_%S"`
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement