Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!mcsun!unido!mikros!mwtech!martin From: martin@mwtech.UUCP (Martin Weitzel) Newsgroups: comp.unix.shell Subject: Re: Retaining file modification times Message-ID: <1144@mwtech.UUCP> Date: 23 May 91 01:18:11 GMT References: <9105211828.AA12327@fozzie.nrl.navy.mil> Reply-To: martin@mwtech.UUCP (Martin Weitzel) Organization: MIKROS Systemware, Darmstadt/W-Germany Lines: 27 In article <9105211828.AA12327@fozzie.nrl.navy.mil> phillips@FOZZIE.NRL.NAVY.MIL (Lee Phillips) writes: > >I want to do something to a file without changing its modification >time. I suppose I can write a script to get the time from ls, do the >modification, then restore the time (after converting it to numerical >format) with /usr/5bin/touch, but I'm hoping that there is an easier >way. (Csh solutions preferred.) Not quite what you want, but maybe an idea how to solve this problem in a general way: Write a C program (let's call it "cmtime") which stat(2)-s all its arguments (maybe except the first one) and if an argument is an existing file notes the st_mtime (and eventually st_atime) together with the file name. Then "cmtime" fork(2)-s a new process that exec(2)-s the program named as first command line argument to "cmtime", passing all other command line arguments. After the child terminates (for which the parent has waited) the parent resets all the mtime-s to the values noted during the startup phase. Incidentally I have written "cmtime" several years ago and hence know that it's no utterly complicated piece of software. (I don't have the source on the system from which I'm posting this, otherwise I would have included it. If you're in *real* need for the source I could try to fetch it from the other place.) -- Martin Weitzel, email: martin@mwtech.UUCP, voice: 49-(0)6151-6 56 83