Edit: As noted in the comments, tar
modifies the mtime and ctime of the extracted files to match the dates in the archive, so this first method won't work unless the -m
flag was used during extraction. The last method is optimal, but may result in deleting files you want if filenames collide.
find
supports a -newer
file
flag, specifying it should find files newer than file. touch
has a -t argument to modify the access/modify time on a file. So to fix an oops that occurred around 7:25:30 PM:
$ tar xzf whoops.tar.gz
$ touch -t 200909261925.30 whoops-timestamp
$ find . -newer whoops-timestamp
And if you're confident that displayed the correct files:
$ find . -newer whoops-timestamp -print0 | xargs -0 rm -v
An alternative is to delete all the files listed in the archive you just extracted:
$ tar tfz whoops.tar.gz | xargs rm -v