Another point, that last argument for the excluded directory has to have
exactly the same naming format as the directory you're tarring even if
it really means the same thing, i.e. you'd agree that if you're
in /etc directory that "/etc/yum.repos.d" and "yum.repos.d" are
really the same directory but tar isn't that smart you have to
tell it the same formatting since it just compares the strings
in a dumb manner.
In the above if I read it literally:
Code:
tar -cvf test.tar directory_name --exclude=/directory_name/sub-directory
has no a leading slash on "directory_name" then
you're doing a relative path, so your --exclude= value has to
also be relative so don' t use the "/" after the "="
Code:
tar -cvf test.tar directory_name --exclude=directory_name/sub-directory
I tested this by tarring a file to my home directory while occuping
the /etc directory and tarring yum.repos.d
Works incorrectly with "/" after =
Code:
$> pwd
/etc
$> tar cvf /home/mos/foo.tar yum.repos.d --exclude=/etc/yum.repos.d/unused
yum.repos.d/
yum.repos.d/fedora-extras.repo
yum.repos.d/dries.repo
yum.repos.d/macromedia-i386.repo
yum.repos.d/freshrpms.repo
yum.repos.d/fedora-core.repo
yum.repos.d/unused/
yum.repos.d/unused/livna-testing.repo
yum.repos.d/unused/fedora-extras-development.repo
yum.repos.d/unused/fedora-development.repo
yum.repos.d/unused/fedora-updates-testing.repo
yum.repos.d/unused/livna-devel.repo
yum.repos.d/unused/fedora-legacy.repo
yum.repos.d/fedora-updates.repo
yum.repos.d/livna.repo
Works correctly
Code:
$> tar cvf /home/mos/foo.tar yum.repos.d --exclude=yum.repos.d/unused
yum.repos.d/
yum.repos.d/fedora-extras.repo
yum.repos.d/dries.repo
yum.repos.d/macromedia-i386.repo
yum.repos.d/freshrpms.repo
yum.repos.d/fedora-core.repo
yum.repos.d/fedora-updates.repo
yum.repos.d/livna.repo
Mark