Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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.

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

1 Answer 1

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
3  
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
2  
@richardtk_1 - I've added #triplee's comment into #JosephR's answer. –  slm Jul 12 '13 at 15:08

Your Answer

 
discard

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.