[net.unix] How to obtain file date rather than current date

abrams@MITRE.arpa (Marshall D. Abrams) (10/04/86)

I am using troff with the ms macros to produce hardcopy of a file
which is getting many updates.  When I print it I am using the DA
directive to get the date printed on the hardcopy.  But this is the
date printed.  I would much rather have the date that the file
was last revised.  Any suggestion on how to do this would be
appreciated.

Please respond directly, as I am not on the list.

Thank you.

Sincerely,

 - Marshall D. Abrams, phone: (703) 883-6938
   The MITRE Corporation, 7525 Colshire Drive
   Mail Stop W458, Mc Lean, VA   22102

waynet@tolerant.UUCP (Wayne Thompson) (10/06/86)

> I am using troff with the ms macros to produce hardcopy of a file
> which is getting many updates.  When I print it I am using the DA
> directive to get the date printed on the hardcopy.  But this is the
> date printed.  I would much rather have the date that the file
> was last revised.  Any suggestion on how to do this would be
> appreciated.
> 
> Please respond directly, as I am not on the list.
> 
> Thank you.
> 
> Sincerely,
> 
>  - Marshall D. Abrams, phone: (703) 883-6938
>    The MITRE Corporation, 7525 Colshire Drive
>    Mail Stop W458, Mc Lean, VA   22102
I followed this up with a reply, but felt that this might well be broadcast.
----------------------------------------------------------------------
I was intrigued by your problem. I have avoided learning formatters, but
had to start friday. The key to solving your problem is using the power
unix to interface many different programs to produce the desired result.
First, create a file which looks like this:

#! /bin/sh
ls -l $1 | awk '{ print ".DA" $5 " " $6 " " $7" }' > mod.date
troff -ms $1
exit

Let's call it modroff.

You must then make make modroff executeable by executing:

chmod 744 modroff

This will make the file that you just created executeable.
Additionally, the file modroff must by in your search_path.
I will assume that you are using /bin/cshrc for your shell (if your
using /bin/sh ask for loacl help or send me email.
My search path includes my own personal executeable directly with the
inclusion of th following addtion to my ~/.login:

set mail=/usr/spool/mail/$user
alias msgs msgs -p
if (-e /b/other/.login) source /b/other/.login
***setenv PATH ~/bin:${PATH}:/usr/lib/news
fortune -a
checknews

*** <- is for illustration and not included in the original file.

What that means is that my search path for executeable files will be
my personal ~/bin directory followed by what's included in /b/other/.login
followed by /usr/lib/news (which on my system includes uu{en,de}code).

So the point of all this is that the directory ~/bin is included in your
search path (which may be a good place for your file modroff).

modroff will produce the file mod.date which will contain:

.DA "last modified"

The file which you would like to print MUST include the following
statement:

.so mod.date

You would invoke troff with the command

% modroff filename

P. S.
   I hope you won't be offended by my detail, but I felt it were better to
include all details and assume you weren't familiar with other aspects of
unix.
-- 
Which is worse ignorance or apathy? Who knows, who cares.

Wayne Thompson
..{bene,mordor,nsc,oliveb,pyramid,ucbvax}!tolerant!waynet

Your mission, should you decide to accept it, is to discern who is
responsible for these opinions, the poster or the company he works for.
Good luck!!

dave@sq.UUCP (10/09/86)

In article <4353@brl-smoke.ARPA> abrams@MITRE.arpa (Marshall D. Abrams) writes:
>I am using troff with the ms macros to produce hardcopy of a file
>which is getting many updates.  When I print it I am using the DA
>directive to get the date printed on the hardcopy.  But this is the
>date printed.  I would much rather have the date that the file
>was last revised.  Any suggestion on how to do this would be
>appreciated.

The following troff macro, gR (GetReviseTime), assigns the latest
revision-date of the file in which it appears to the string whose name
is the argument in a call to gR:

.de gR
.sy echo ".ds \\$1 `ls -l \n(.F | awk '{print $5, $6, $7}'`">/tmp/date\n($$
.so /tmp/date/\n($$
.sy rm /tmp/date\n($$

After the above, in the file which is being formatted by ms, the
following:

.gR dR
\*(dR

would place the respective date in the output. It also works independent
of the ms macros.

Note: the .sy request is available in DWB and ditroff.

--------------------------------------------------------------
SoftQuad	Toronto, Ontario, Canada	(416) 963-8337
David Seaman	utzoo!sq!dave

dave@sq.UUCP (10/09/86)

In article <1986Oct8.182034.4245@sq.uucp> dave@sq.UUCP I write:
>  The following troff macro, gR (GetReviseTime), assigns the latest
>  revision-date of the file in which it appears to the string whose name
>  is the argument in a call to gR:
>  
>  .de gR
>  .sy echo ".ds \\$1 `ls -l \n(.F | awk '{print $5, $6, $7}'`">/tmp/date\n($$
>  .so /tmp/date/\n($$
>  .sy rm /tmp/date\n($$
>  
>  After the above, in the file which is being formatted by ms, the
>  following:
>  
>  .gR dR
>  \*(dR
>  
>  would place the respective date in the output. It also works independent
>  of the ms macros.
>  
>  Note: the .sy request is available in DWB and ditroff.

Sorry folks. (Apologies in particular to beginners.)
The macro definition, above (gR), contains two typos:

	1. There should be a line ".." at the bottom, to end
	   the definition.
	2. An extra forward-slash appears in the ".so ..." line 
	   following the word "date".

The true definition is:

  .de gR
  .sy echo ".ds \\$1 `ls -l \n(.F | awk '{print $5, $6, $7}'`">/tmp/date\n($$
  .so /tmp/date\n($$
  .sy rm /tmp/date\n($$
  ..

sja@ih1ap.UUCP (Steve Alesch) (10/10/86)

Try troff `/usr/lib/manprog` ...
See man(1) for more info.
-- 

Steve Alesch	AT&T
(312)510-7881, ...!ihnp4!ih1ap!sja