[OS X TeX] Re: Save date-time, not Print date

Victor Ivrii vivrii at gmail.com
Sun Jan 7 19:47:17 CET 2007


On 1/7/07, Robert Bruner <rrb at math.wayne.edu> wrote:
> Thanks to Victor Ivrii for showing us how easy this is:
>
> > > \immediate\write18{ls -l \file.tex | cut -b33-45 > \file.date}
> > > \input\file.date
>
> Several comments:
>
> 1. ls -l gives variable results, viz
>
>    rrb% ls -l
>    total 2720
>    -rw-r--r--    1 rrb  wheel    1288 Jun  7  2006 L2.txt
>    drwx------   31 rrb  rrb      1054 Jan  5 10:55 Library/
>
> Note that one entry is Jun 7 2006, the other is Jan 5 10:55.
> This is why I suggested ls -lT.
>
>    rrb% ls -lT
>    total 2720
>    -rw-r--r--    1 rrb  wheel    1288 Jun  7 12:20:57 2006 L2.txt
>    drwx------   31 rrb  rrb      1054 Jan  5 10:55:45 2007 Library/
>
> We get uniform results from which we can confidently extract the
> year rather than time of day.

Agreed
>
> 2.  If file.date aready exists, the redirection ( ...  > \file.date)
> will fail.  Appending is not in order, so it would seem necessary to
> remove file.date before writing to it.

Normally it will be overwritten (at least in tcsh)
>
> 3. awk allows easy rewriting of the order of the parts of the date,
> e.g. (and incorporating removal of file.date
>
>     \immediate\write18{rm -f \file.date; ls -lT \file.tex | awk '{print $8" "$7" "$6" "$9}' > \file.date}
>
> will rewrite
>    -rw-r--r--    1 rrb  wheel    1288 Jun  7 12:20:57 2006 L2.txt
> as
>    12:19:06 10 Dec 2006

Agreed

>
> Naturally, you may have your wn preference for the order (day-month-year, etc.
> And my preference for awk is one of those 'you use the tools you know' moments.
>
> 4. What I wrote above will alomost certainly fail without some additional care
> to make certain that the braces ({}) are passed properly by tex to the shell.
>


The problem however is that timestamp is affected by certain
operations which actually do not change file. To make things even
worse TeXShop actually saves .tex file every time it typesets it; so
it will be by no means different from using \today unless  TeXShop
configured for external editor (so editing function of TeXShop is
switched off


-- 
========================
Victor Ivrii, Department of Mathematics, University of Toronto
http://www.math.toronto.edu/ivrii

------------------------- Helpful Info -------------------------
Mac-TeX Website: http://www.esm.psu.edu/mac-tex/
TeX FAQ: http://www.tex.ac.uk/faq
List Archive: http://tug.org/pipermail/macostex-archives/
List Reminders & Etiquette: http://www.esm.psu.edu/mac-tex/list/





More information about the macostex-archives mailing list