setting or retaining the date of a file
Paul Falstad
pfalstad at phoenix.Princeton.EDU
Sat Mar 30 17:04:11 AEST 1991
phil at ux1.cso.uiuc.edu (Phil Howard KA9WGN) wrote:
>I have a bunch of files in which the date of the file has a particular
>meaning to me. I want to retain the dates. However I also want to sort
>these files as well. I don't want to end up with a bunch of sorted files
>dated today.
I believe the system V version of touch can change file datestamps. At
least, /usr/5bin/touch on a SunOS system can do it.
Of course, it's trivial to write (this is sans error checking):
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/time.h>
main(argc,argv)
int argc;
char **argv;
{
struct stat buf;
struct timeval x[2];
stat(argv[1],&buf);
x[0].tv_sec = buf.st_atime;
x[1].tv_sec = buf.st_mtime;
utimes(argv[2],x);
}
--
Paul Falstad, pfalstad at phoenix.princeton.edu | 10 PRINT "PRINCETON CS"
[Your blood pressure just went up.] | 20 GOTO 10
Princeton University would like to apologize to everyone for this article.
More information about the Comp.unix.questions
mailing list