3

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:

    analyze:
            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.

1
  • UUCA waning -- you mean <$(foo) tokenize.pl.
    – tripleee
    Commented Jul 12, 2013 at 14:26

1 Answer 1

7

Instead of TIMESTAMP, put

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

in your one-liner recipe.

4
  • 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. Commented Jul 12, 2013 at 14:19
  • Might need some zero padding to force hhe output to always be teo digits, i.e. %02m pro %m, etc.
    – tripleee
    Commented Jul 12, 2013 at 14:27
  • 6
    Because Make eats one dollar sign, you need $$(date...).
    – tripleee
    Commented Jul 12, 2013 at 14:29
  • 2
    @richardtk_1 - I've added #triplee's comment into #JosephR's answer.
    – slm
    Commented Jul 12, 2013 at 15:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .