Go to the previous, next section.
(This message will disappear, once this node revised.)
While the `--list' (`-t') operation with the `--verbose' (`-v') option
specified is useful in keeping files in the archive current with files
in the file system (by allowing the user to compare size and
modification dates), it is simpler to have tar
itself compare
file attributes and report back on file differences. To do so, use
the `--compare' (`-d') or `--diff' operation.
The `--compare' (`-d') operation, as its name implies, causes tar
to compare files and directories in the archive with their
counterparts (files of the same name) in the file system, and report
back differences in file size, mode, owner and modification date.
When performing the `--compare' (`-d') operation, tar
acts only on
files actually in the archive--it will ignore files in the active
file system that do not exist in the archive. If tar
with
`--compare' (`-d') specified is given, as a file name argument, the name
of a file that does not exist in the archive, it will return an error
message.
To compare the files in the practice directory with their counterparts in the archive file `records', in the same directory, you would, while in the `practice' directory:
tar
and specify the operation to compare files in the
archive with their counterparts in the file system---`--compare' (`-d')
or `--diff'.
% tar --compare --file=records %
While it looks like nothing has happened, tar
has, in fact,
done the comparison--and found nothing to report. The same example
with the `--verbose' (`-v') option specified would list the files in the
archive as they are being compared with their counterparts of the same
name:
% tar --compare --verbose --file=records blues folk jazz %
If tar
had had anything to report, it would have done so as it
was comparing each file. If you remove the file `jazz' from the
file system (`rm jazz'), and modify the file `blues' (for
instance, by adding text to it with a text editor), the above example
would look like:
% tar --compare --verbose --file=records blues blues: mod time differs blues: size differs folk jazz jazz: does not exist %
You should note again that while `--compare' (`-d') does cause tar
to report back on files in the archive that do not exist in the file
system, tar
will ignore files in the active file system that do
not exist in the archive. To demonstrate this, create a file in the
`practice' directory called `rock' (using any text editor).
If you generate a directory listing the new file will appear.
% ls blues folk records rock
If you run the `--compare' (`-d') example again you will obtain the following:
% tar --compare --verbose --file=records blues blues: mod time differs blues: size differs folk jazz jazz: does not exist %
tar
ignores the file `rock' because tar
is
comparing files in the archive to files in the file system, not vice
versa. If `rock' had been passed to tar
explicitly (as a
file name argument), tar
would have returned an error message,
as follows:
% tar --compare --verbose --file=records rock tar: rock not found in archive %
To compare the attributes of archive members with the attributes of
their counterparts in the file system, use the `--compare' (`-d') or
`--diff'operation. While you could use `--list --verbose'
(`-tv') to manually compare some file attributes, it is simpler
to have tar
itself compare file attributes and report back on
file differences.
FIXME: "manually"? suggestions?
The `--compare' (`-d') operation, as its name implies, compares archive
members with files of the same name in the file system, and reports
back differences in file size, mode, owner and modification date. `tar
+compare' acts only on archive members--it ignores files in the file
system that are not stored in the archive. If you give with
`--compare' (`-d')
a name argument that does not correspond to the name of an archive
member, tar
responds with an error message.
To compare archive members in the archive file `records' with files in the `~/practice' directory, first change into the `practice' directory. Then:
tar
and specify the `--compare' (`-d')
operation---`--compare' (`-d') or `--diff'.
% tar --compare --file=records %
While it looks like nothing has happened, tar
has, in fact, done the
comparison--and found nothing to report.
Use the `--verbose' (`-v') option to list the names of archive members as they are being compared with their counterparts of the same name in the file system:
% tar --compare --verbose --file=records blues folk jazz %
If tar
had had anything to report, it would have done so as it was
comparing each file.
If you remove the file `jazz' from the file system (`rm jazz'), and modify the file `blues' (for instance, by adding text to it with an editor such as Emacs), the above example would look like:
% tar --compare --verbose --file=records blues blues: mod time differs blues: size differs folk jazz jazz: does not exist %
Note again that while `--compare' (`-d') reports the names of archive members that do not have counterparts in the file system, `--compare' (`-d') ignores files in the file system that do not have counterparts in the archive. To demonstrate this, create a file in the `practice' directory called `rock' (using any text editor). The new file appears when you list the directory's contents:
FIXME: Given an example
Go to the previous, next section.