Go to the first, previous, next, last section, table of contents.


Operating Only on New Files

@UNREVISED

The --after-date=date (--newer=date, -N date) option causes tar to only work on files whose modification or inode-changed times are newer than the date given. If you use this option when creating or appending to an archive, the archive will only include new files. If you use `--after-date' when extracting an archive, tar will only extract files newer than the date you specify.

If you only want tar to make the date comparison based on modification of the actual contents of the file (rather than inode changes), then use the --newer-mtime=date option.

You may use these options with any operation. Note that these options differ from the --update (-u) operation in that they allow you to specify a particular date against which tar can compare when deciding whether or not to archive the files.

--after-date=date
--newer=date
-N date
Only store files newer than date. Acts on files only if their modification or inode-changed times are later than date. Use in conjunction with any operation.
--newer-mtime=date
Acts like --after-date=date (--newer=date, -N date), but only looks at modification times.

These options limit tar to only operating on files which have been modified after the date specified. A file is considered to have changed if the contents have been modified, or if the owner, permissions, and so forth, have been changed. (For more information on how to specify a date, see section Date input formats; remember that the entire date argument must be quoted if it contains any spaces.)

Gurus would say that --after-date=date (--newer=date, -N date) tests both the mtime (time the contents of the file were last modified) and ctime (time the file's status was last changed: owner, permissions, etc) fields, while --newer-mtime=date tests only mtime field.

To be precise, --after-date=date (--newer=date, -N date) checks both mtime and ctime and processes the file if either one is more recent than date, while --newer-mtime=date only checks mtime and disregards ctime. Neither uses atime (the last time the contents of the file were looked at).

Date specifiers can have embedded spaces. Because of this, you may need to quote date arguments to keep the shell from parsing them as separate arguments.

@FIXME{Need example of --newer-mtime with quoted argument.}

Please Note: --after-date=date (--newer=date, -N date) and --newer-mtime=date should not be used for incremental backups. Some files (such as those in renamed directories) are not selected properly by these options. See section The Incremental Options.

To select files newer than the modification time of a file that already exists, you can use the `--reference' (`-r') option of GNU date, available in GNU shell utilities 1.13 or later. It returns the timestamp of that already existing file; this timestamp expands to become the referent date which `--newer' uses to determine which files to archive. For example, you could say,

$ tar -cf archive.tar --newer="`date -r file`" /home

which tells @FIXME{need to fill this in!}.


Go to the first, previous, next, last section, table of contents.