[comp.unix.questions] touch

maujd@warwick.UUCP (Geoff Rimmer) (06/21/88)

In article <344@ajpo.sei.cmu.edu> jrkelly@ajpo.sei.cmu.edu (John Kelly) writes:
>
>Has anyone implemented any of the following for Unix:
>
>  1. a directory listing command with a -since option?
>  2. a program to force a specified modification time upon a specified file?
>  3. a program to compare two dates/times and return an appropriate status?
>
>where the dates/times are given in string form, as in the output of "date" and
>"ls"?

Although I haven't done #1, I would have thought it would be a fairly
easy C routine to write.  Use readdir(3) to step thru the files, and
stat(2) to find the modify time - then only print the info if the file
is after the time/date specified by -since.

#2 is already implemented on our (system V version) touch(1V) :-

----------------------------------------------------------------------
NAME
     touch - update times of last access and  modification  of  a
     file

SYSTEM V SYNOPSIS
     touch [ -c ] [ -a ] [ -m ] [ mmddhhmm[yy] ] filename ...

DESCRIPTION
     touch causes the access and modification times of each argu-
     ment to be set to the current time.  A file is created if it
     does not already exist.

OPTIONS
     -c   Do not create filename if it does not exist.

     -a   Update only the access time.

     -m   Update only the modification time.

     mmddhhmm[yy]
          Update the times to the specified time rather  than  to
          the current time.  The first mm is the month, dd is the
          day of the month, hh is the hour, and the second mm  is
          the  minute;  if  yy  is  specified, it is the last two
          digits of the year, otherwise the current year is used.

----------------------------------------------------------------------
Don't know about #3.

Geoff
	------------------------------------------------------------
	Geoff Rimmer, Computer Science, Warwick University, UK.
			maujd@uk.ac.warwick.opal

	"Oh, don't be so sentimental mother, things explode every day."
	------------------------------------------------------------

friedl@vsi.UUCP (Stephen J. Friedl) (06/24/88)

In article <712@ubu.warwick.UUCP>, maujd@warwick.UUCP (Geoff Rimmer) writes:
> [various talking about times and dates of files]
> 
> ----------------------------------------------------------------------
> NAME
>      touch - update times of last access and  modification  of  a
>      file
> 
> SYSTEM V SYNOPSIS
>      touch [ -c ] [ -a ] [ -m ] [ mmddhhmm[yy] ] filename ...

Just an unrelated tidbit for you folks who can't remember the format
for the date command in set-the-date mode.  On Sys V, touch's usage
message includes the format for the date: it's the same as date's.
I always use "-x", which is an illegal arg, and it looks like:

	touch: illegal option -- x
	usage: touch [-amc] [mmddhhmm[yy]] file ...

Just for fun...
-- 
Steve Friedl    V-Systems, Inc. (714) 545-6442      3B2-kind-of-guy
friedl@vsi.com     {backbones}!vsi.com!friedl    attmail!vsi!friedl

Nancy Reagan on the Mac-II architecture: "Just say Nu"

kent@tifsie.UUCP (Russell Kent) (06/24/88)

in article <712@ubu.warwick.UUCP>, maujd@warwick.UUCP (Geoff Rimmer) says:
> In article <344@ajpo.sei.cmu.edu> jrkelly@ajpo.sei.cmu.edu (John Kelly) writes:
>>
>>Has anyone implemented any of the following for Unix:
>>
>>  1. a directory listing command with a -since option?
>>  2. a program to force a specified modification time upon a specified file?
>>  3. a program to compare two dates/times and return an appropriate status?
>>
>>where the dates/times are given in string form, as in the output of "date" and
>>"ls"?
> 
> #2 is already implemented on our (system V version) touch(1V) :-

As Geoff noted, SYSV touch allows you to set the date to a specific time,
whether future or past.  BSD touch does not however.  But then again, BSD
will "force" a touch (via an -f option) even if the file is not writable
(assuming you own the file or are the superuser).  At my last check, SYSV
has no provision to do this (Clarification anyone?).

I got frustrated enough at the "gratuitous differences" between BSD
and SYSV on this point that I wrote my own.  It is written entirely
without reference to BSD or SYSV source, but implements both features
from BSD and SYSV.  If some kind soul will mail instructions on how
to distrubute via comp.unix.sources, I will share.  For those of you
who can't wait, send me mail and I will email directly.

John Kelly: I would have emailed the source directly to you, but my mailer
doesn't know how to get to you.  (Dumb ain't it)  If you can come up with
a bang-style address, I'll send it to you.


Russell Kent                    Phone: +1 214 995 3501
Texas Instruments               UUCP address:
P.O. Box 655012   MS 3635       ...!convex!smu!tifsie!kent
Dallas, TX 75265                ...!ut-sally!im4u!ti-csl!tifsie!kent
-- 
Russell Kent                    Phone: +1 214 995 3501
Texas Instruments               UUCP address:
P.O. Box 655012   MS 3635       ...!convex!smu!tifsie!kent
Dallas, TX 75265                ...!ut-sally!im4u!ti-csl!tifsie!kent