Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a Makefile which I invoke using the following command:

    $ make analyze foo=History01

I have the following Makefile and I need to attached the timestamp to the name of the log file:

            cat $(foo) | perl tokenize.pl | flookup spanmorph.fst 2>&1 | tee -a $(foo)TIMESTAMP.log

Instead of TIMESTAMP I need the system timestamp (when the log file is created) with the format yyyyMMddHHmmss

I am a Ubuntu user by the way and I am not really experienced with Linux, I would be grateful for any answer. Thanks in advance.

share|improve this question
UUCA waning -- you mean <$(foo) tokenize.pl. – tripleee Jul 12 '13 at 14:26
up vote 4 down vote accepted

Instead of TIMESTAMP, put

$$(date +%Y%m%d%H%M%S)

in your one-liner recipe.

share|improve this answer
I have tried what you indicated me but the timestamp doesn't appear, although the log file is created but its name doesn't contain the timestamp as expected. – richardtk_1 Jul 12 '13 at 14:19
Might need some zero padding to force hhe output to always be teo digits, i.e. %02m pro %m, etc. – tripleee Jul 12 '13 at 14:27
Because Make eats one dollar sign, you need $$(date...). – tripleee Jul 12 '13 at 14:29
Thanks #tripleee. It worked with $$(date +%Y%m%d%H%M%S) – richardtk_1 Jul 12 '13 at 14:33
@richardtk_1 - I've added #triplee's comment into #JosephR's answer. – slm Jul 12 '13 at 15:08

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.