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.

  • UUCA waning -- you mean <$(foo) tokenize.pl. – tripleee Jul 12 '13 at 14:26

Instead of TIMESTAMP, put

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

in your one-liner recipe.

  • 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
  • 6
    Because Make eats one dollar sign, you need $$(date...). – tripleee Jul 12 '13 at 14:29
  • 2
    @richardtk_1 - I've added #triplee's comment into #JosephR's answer. – slm Jul 12 '13 at 15:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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