revert - set back timestamps on identical files

Tools like make(1) look at a file's timestamp to determine if it needs to be processed again. But they can do unnecessary work in cases when the file's contents are unchanged even though the modification time is more recent. This can happen when, for example, you do search-and-replace on lots of source files with perl -i (and it fails to find any matches in some of the files) or when the files are themselves generated programmatically.

This tool, revert, looks at the source files you tell it and compares them with those in the destination directory. If there are duplicate files in the destination, their timestamp is set back to reflect the fact that they have not really changed. Usage of revert should be fairly similar to cp(1), but you are 'copying' timestamps instead of file contents.

For example if you wanted to make bulk edits to some source files using perl, but if a file did not get changed you want to keep the old timestamp:

% mkdir old
% cp -p *.c old
% perl -i -pe s/fred/jim/ *.c
% revert old/* .

Note two things. First, revert does not change anything except the modification time of the destination files. Second, it will not change the modification time except to copy it from the corresponding source file if that file has identical content.


Author and copying

Copyright 2003 Ed Avis. This is free software; you may distribute it under the GNU General Public License, version 2 or (at your option) any later version.

Please contact me at with suggestions or bug reports.

Ed Avis
Last modified: Sat Feb 1 23:11:28 GMT 2003