Ftimes - output time statistics for a file
De onbekende kat
ken at rochester.UUCP
Fri Sep 27 05:06:24 AEST 1985
/bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create the files:
# ftimes.1
# ftimes.c
# This archive created: Thu Sep 26 15:03:31 1985
# By: De onbekende kat (Het 9de leven)
export PATH; PATH=/bin:$PATH
if test -f 'ftimes.1'
then
echo shar: over-writing existing file "'ftimes.1'"
fi
cat << \SHAR_EOF > 'ftimes.1'
.TH FTIMES 1
.SH NAME
ftimes \- display access, change and modify times of a file
.SH SYNOPSIS
.B ftimes
[
\fB\-acm\fR
] file
.SH DESCRIPTION
.IR Ftimes
displays the access, change and modify times of a file in seconds
past the epoch (1 January 1970).
This is useful for making decisions in shell scripts.
.PP
Flags a, c and m select the corresponding times.
If no option is selected, the default is the modify time.
.PP
Example:
.br
.nf
.in +5
if test `ftimes RCS/file,v` -gt `ftimes file`
then
co file
fi
.in -5
.fi
is a shell script to check out a RCS file if a newer version
has been checked in since the working version was created.
.SH AUTHOR
Ken Yap (University of Rochester)
SHAR_EOF
if test 686 -ne "`wc -c 'ftimes.1'`"
then
echo shar: error transmitting "'ftimes.1'" '(should have been 686 characters)'
fi
if test -f 'ftimes.c'
then
echo shar: over-writing existing file "'ftimes.c'"
fi
cat << \SHAR_EOF > 'ftimes.c'
/*
** ftimes [-acm] file
**
** Output the access, change and modify times of the file in seconds
** past the epoch (1 Jan 1970). If no flag is selected, the default
** is the modify time.
**
** This is public domain software. It may be freely distributed,
** modified and used. Please use it for peaceful purposes
** and also not for profit.
**
** Bug reports and comments to:
**
** Ken Yap (ken at rochester.{arpa,uucp})
**
** I do not promise any sort of support or warrant the
** suitability of this software for any purpose whatsoever.
**
** Last modified:
**
** Ken Yap (ken at rochester.{arpa,uucp}) 26th Sep 1985
*/
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
static int aflag = 0, /* display access time */
cflag = 0, /* display change time */
mflag = 0; /* display modify time */
main(argc, argv)
int argc;
char *argv[];
{
register int n, errflag = 0;
struct stat sb;
extern int optind; /* defined in getopt */
extern char *optarg; /* defined in getopt */
int getopt(), stat();
while ((n = getopt (argc, argv, "acm")) != EOF)
{
switch (n)
{
case 'a':
aflag++; break;
case 'c':
cflag++; break;
case 'm':
mflag++; break;
default:
errflag++; break;
}
}
argc -= optind;
if (errflag || argc != 1)
{
fprintf(stderr, "usage: %s [-acm] file\n", argv[0]);
exit(2);
}
argv += optind;
if (stat(argv[0], &sb) < 0)
{
perror(argv[0]);
exit(1);
}
if (!aflag && !cflag)
mflag = 1; /* at least mod time */
if (aflag)
printf("%ld ", sb.st_atime);
if (cflag)
printf("%ld ", sb.st_ctime);
if (mflag)
printf("%ld ", sb.st_mtime);
printf("\n");
exit(0);
}
SHAR_EOF
if test 1640 -ne "`wc -c 'ftimes.c'`"
then
echo shar: error transmitting "'ftimes.c'" '(should have been 1640 characters)'
fi
# End of shell archive
exit 0
--
UUCP: ..!{allegra,decvax,seismo}!rochester!ken ARPA: ken at rochester.arpa
USnail: Dept. of Comp. Sci., U. of Rochester, NY 14627. Voice: Ken!
More information about the Comp.sources.unix
mailing list